-
Notifications
You must be signed in to change notification settings - Fork 216
Open
Description
Hi everyone,
I'm using the cascade
operator in many kinds of scenarios and I'm very grateful for it.
There is an issue though, when for some reason the last observable completes immediately (i.e. in a synchronous manner), the resulting cascading observable will not complete.
I believe that is because of the if initialized
test when subscribing to underlying observables: https://github.com/RxSwiftCommunity/RxSwiftExt/blob/master/Source/RxSwift/cascade.swift#L57
For example, if the last observable in the list is a .just(whatever)
, the cascade will never complete.
It looks like it's a regression that was introduced with commit 4ba2dd6
The following test can help understand the issue (it's red at the moment):
func testSynchronousCompletion() {
let xs = scheduler.createHotObservable([
.next(110, 1),
.next(180, 2),
.next(230, 3),
.next(270, 4),
.next(340, 5),
.completed(200)
])
.asObservable()
let ys = scheduler.createHotObservable([
.next(100, 21),
.completed(210, Int.self)
])
.asObservable()
let zs = Observable<Int>.just(31)
let res = scheduler.start { () -> Observable<Int> in
Observable.cascade([xs, ys, zs])
}
XCTAssertEqual(res.events, [
.next(200, 31),
.completed(200)
]) // <--- it's just `[.next(200, 31)`
}
Metadata
Metadata
Assignees
Labels
No labels