ReactiveX/RxSwift

TakeUntil Different Working from Docs

yudonlee opened this issue · 5 comments

⚠️ 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. ⚠️

⚠️ 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 :( ⚠️

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

  • iOS
  • macOS
  • tvOS
  • watchOS
  • playgrounds

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

  • easy, 100% repro
  • sometimes, 10%-100%
  • hard, 2% - 10%
  • extremely hard, %0 - 2%

Xcode version:

  Xcode version goes here

⚠️ 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. ⚠️

Installation method:

  • CocoaPods
  • Carthage
  • Git submodules

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

  • yes (which ones)
  • no

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

  • just starting
  • I have a small code base
  • I have a significant code base

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.

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?

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

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

I submitted a PR.