Last active
April 10, 2021 21:19
-
-
Save jasdev/0fb13c397c1203f5880fa903c776928b to your computer and use it in GitHub Desktop.
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