Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rx’s handling of `withLatestFrom` completions.
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