From 7ade18ba7575387be40a2e57e1afc2646cd49df2 Mon Sep 17 00:00:00 2001 From: Mike Lewis Date: Tue, 17 Nov 2015 14:37:19 -0800 Subject: [PATCH] Making withLatestFrom subscribe to the right hand side first This resolves an issue where you have two observables that yield values immediately and it wasn't yielding a result --- .../Implementations/WithLatestFrom.swift | 2 +- .../Tests/Observable+MultipleTest.swift | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/RxSwift/Observables/Implementations/WithLatestFrom.swift b/RxSwift/Observables/Implementations/WithLatestFrom.swift index a312456b..39a7eb0c 100644 --- a/RxSwift/Observables/Implementations/WithLatestFrom.swift +++ b/RxSwift/Observables/Implementations/WithLatestFrom.swift @@ -32,8 +32,8 @@ class WithLatestFromSink(value: 3) + let ys = BehaviorSubject(value: 5) + + let scheduler = TestScheduler(initialClock: 0) + + + let res = scheduler.start { + xs.withLatestFrom(ys) { x, y in "\(x)\(y)" } + .take(1) + } + + XCTAssertEqual(res.messages, [ + next(200, "35"), + completed(200) + ]) + } + func testWithLatestFrom_Simple2() { let scheduler = TestScheduler(initialClock: 0)