Junior — Senior
Analysis of doOnSubscribe behavior in RxJava chain
livecode
Task condition
In the updateRegions method, getRegions is called, which returns a Single with a list of regions, and the thread does not switch inside the chain. It is necessary to explain on which Scheduler the code passed to doOnSubscribe will be executed.
fun updateRegions() {
getRegions()
.subscribeOn(Schedulers.single())
.observeOn(Schedulers.computation())
.doOnSubscribe {
showProgress()
}
.subscribeOn(Schedulers.io())
.subscribe(
{ regions ->
showRegions(regions)
}
)
}
Describe which thread will be used to call showProgress() and why.