filipradon
09/03/2021, 2:05 PM@Test fun `completeable trampoline test`() {
Completable.defer { Completable.complete() }
.doOnComplete { println("I'm completing!") }
.andThen(
Completable.complete()
.timeout(1, TimeUnit.SECONDS, Schedulers.trampoline())
.doOnComplete { println("I'm not completing ! :( ") }
)
.subscribeOn(Schedulers.trampoline())
.test()
.assertComplete()
// timeout exception is thrown
}
It's not completing. It's throwing TimeoutError. I'm wondering how this chain is actually executed. I know Trampoline is putting a thread to sleep when used in timeout
for example but my question is
why the Completables do not complete (or actually only the second Completable) before that actually happens.
(PS. I'm aware that TestSchedulers should be used, it's just for better understanding purposes)