Hey Ryan,
that is a great question, people are a bit confused about that one — probably it deserves a section in the post. But for now let me give an example (is Kotlin ok?) :
Observable.fromCallable { 1 }
.flatMap { Observable.fromCallable { 2 }.subscribeOn(Schedulers.newThread()) }
.subscribeOn(Schedulers.computation())
.subscribe { Log.e("LOG", it.toString()) }
Returning number 1
is done on computation
scheduler.
Returning number 2
inside of flatMap
will happen on newThread
scheduler, which makes sense as subscribeOn
says to use the given scheduler when the fromCallable { 2 }
starts. If we wouldn’t put subscribeOn
with newThread
then it would use the current one (computation
).
So in the end the logging inside subscribe
will happen on newThread
scheduler.
Does it answer your question?