Is it true for combineLast operator too ?
AbdelAli Eramli
1

Yes, it’s also true for combineLatest.

I created following snippet similar to the one on the article

    val observable1 = createObservable1()
val observable2 = createObservable2()

Observable.combineLatest(observable1, observable2, BiFunction<String, String, String> { a, b -> "$a $b" })
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(
onNext = { println(it)},
onError = { onError() }
)
...
private fun createObservable1(): Observable<String> {
return Observable.create<String> {
println("START processData1 (${getElapsedTime()}s) on thread: ${Thread.currentThread().name}")
Thread.sleep(2000)
it.onNext("hello")
Thread.sleep(1000)
it.onNext("it's")
println("STOP processData1 (${getElapsedTime()}s)")
}
}

private fun createObservable2(): Observable<String> {
return Observable.create<String> {
println("START processData2 (${getElapsedTime()}s) on thread: ${Thread.currentThread().name}")
Thread.sleep(2500)
it.onNext("world")
Thread.sleep(500)
it.onNext("me")
println("STOP processData2 (${getElapsedTime()}s)")
}
}

And got following result:

But if you apply subscriber to each observable both threads run in parallel and you got following result: