ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.37k stars 4.17k forks source link

TakeUntil Different Working from Docs #2473

Closed yudonlee closed 6 months ago

yudonlee commented 1 year ago

:warning: If you don't have something to report in the following format, it will probably be easier and faster to ask in the slack channel first. :warning:

:warning: Please take you time to fill in the fields below. If we aren't provided with this basic information about your issue we probably won't be able to help you and there won't be much we can do except to close the issue :( :warning:

If you still want to report issue, please delete above statements before submitting an issue.

Short description of the issue: TakeUntil Docs Says

If this second Observable emits an item or sends a termination notification, the Observable returned by TakeUntil stops mirroring the source Observable and terminates

But if Second Observable terminates, Source observer still can emit the item. description here

Expected outcome:

onNext("A")
onNext("B")

What actually happens:

onNext("A")
onNext("B")
onNext("C")

Self contained code example that reproduces the issue:


let subject = PublishSubject<String>()
let trigger = PublishSubject<String>()

        subject
            .take(until: trigger)
            .subscribe(onNext: {
                print($0)
            })
            .disposed(by: disposBag)

        subject.onNext("A")
        subject.onNext("B")
        trigger.onCompleted()
        subject.onNext("C")

RxSwift/RxCocoa/RxBlocking/RxTest version/commit 6.0.0 version or commit here

Platform/Environment

How easy is to reproduce? (chances of successful reproduce after running the self contained code)

Xcode version:

  Xcode version goes here

:warning: Fields below are optional for general issues or in case those questions aren't related to your issue, but filling them out will increase the chances of getting your issue resolved. :warning:

Installation method:

I have multiple versions of Xcode installed: (so we can know if this is a potential cause of your issue)

Level of RxSwift knowledge: (this is so we can understand your level of knowledge and formulate the response in an appropriate manner)

danielt1263 commented 1 year ago

I believe this is a mistake in the documentation. The observable passed into take(until:) will only terminate the source on an onNext or onError event, not for onCompleted.

This is also how the reference implementation for C# works.

yudonlee commented 1 year ago

I believe this is a mistake in the documentation. The observable passed into take(until:) will only terminate the source on an onNext or onError event, not for onCompleted.

This is also how the reference implementation for C# works.

Thank you! I didn't think the document was wrong. But why doesn't the document change?

danielt1263 commented 1 year ago

Exactly what file are you talking about with incorrect documentation? I invite you to submit a pull request with the file corrected.

yudonlee commented 1 year ago

The document I'm talking about is the official Reactive.io document.! https://reactivex.io/documentation/operators/takeuntil.html

danielt1263 commented 1 year ago

I submitted a PR.