Junior — Senior
Analysis of flatMap behavior in RxJava chain
livecode
Task condition
In the updateRegions method, a Single with a list of regions is returned, and the execution flow inside it does not change. It is necessary to explain on which Scheduler the code inside flatMap(getCity()) will be executed.
fun updateRegions() {
getRegions()
.subscribeOn(Schedulers.single())
.observeOn(Schedulers.computation())
.flatMap {
getCity()
}
.subscribeOn(Schedulers.io())
.subscribe(
{ regions ->
showRegions(regions)
}
)
}
Describe how subscribeOn and observeOn interact in this chain and which thread will be used to call getCity() inside flatMap.