I'd like to know what happens when we have multiple subscribeOn()
methods in a RxJava chain. For instance if I had a chain that was something like this,
Single.fromCallable { repository.apiCall1() }
.subscribeOn(Schedulers.io())
.flatMap { result -> Single.fromCallable { repository.apiCall2() } }
.subscribeOn(Schedulers.io())
.map { // do something }
.observeOn(Schedulers.ui())
would this mean that the thread the API calls run on is not the same? And what would be the impact / effect of removing the first subscribeOn(Schedulers.io())
call in this chain above?
Appreciate any insights on this
subscribeOn()
calls? (would they just create another thread un-necessarily for nothing). Is there some way to test only one thread is actually being created / used? – Wholly