Sobes.tech
Junior — Senior

Definition of onSuccess execution flow in subscription in RxJava

livecode

Task condition

The fetchRegions method returns a Single with a data set, and there is no thread switching inside the stream. Indicate on which Scheduler the code inside the onSuccess handler will be executed.

fun updateRegions() {
    fetchRegions()
        .subscribeOn(Schedulers.io())
        .observeOn(Schedulers.computation())
        .subscribe(
            { regionList ->
                renderRegions(regionList)
            }
        )
}