Nikita Ermolenko Nikita Ermolenko - 9 days ago 7
iOS Question

Merge observables on one type and then chain to obserbable of another type

Are there solutions for chaining Observables of different types?
I want to

merge
Observables, and when each of them sends the
Completed
event, emit the next Observable (
signal
).

Something similar to
ReactiveCocoa
's
then
.

let signal = Observable<String>.create { observer in
observer.onCompleted()
return Disposables.create()
}

let signals: [Observable<Int>] = [Observable.just(1), Observable.just(2), Observable.just(3)]

Observable.from(signals).merge().concat(signal).subscribe {
print("completed")
}

Answer

I implemented this by takeLast(1) and then flatMap to needed Observable.