Rx’s handling of `withLatestFrom` completions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RxSwift | |
// **Scenario one**: `withLatestFrom`’s argument finishes first. | |
let first = PublishSubject<Int>() | |
let second = PublishSubject<Int>() | |
let disposeBag = DisposeBag() | |
first | |
.withLatestFrom(second) | |
.debug() | |
.subscribe() | |
.disposed(by: disposeBag) | |
second.onCompleted() | |
// Outputs (trimmed): | |
// | |
// ``` | |
// -> subscribed | |
// `` | |
// **Scenario two**: Upstream finishes first. | |
// … | |
first.onCompleted() | |
// Outputs (trimmed): | |
// | |
// ``` | |
// -> subscribed | |
// -> Event completed | |
// -> isDisposed | |
// ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment