-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does subscribeOn call order matter? #5459
Comments
Let's walk through what happens in the first case. The chain consist of Just -> DoOnSubscribe -> SubscribeOn -> LambdaObserver operators but the subscription process walks in reverse:
Now if
|
That's a perfect explanation. Thank you very much. |
subscribeOn
call order matter?
Looks like this question has been answered. If you have further input on the issue, don't hesitate to reopen this issue or post a new one. |
Hi @akarnokd, I too had doubts on the ordering of In the below code, the general requirement is that any calls to
The original question (regarding conditionally chaining a Thanks for all your help in assisting me to understand Rx! |
@dakshj Does it work as you expected? -> You are done! Does it behave unexpectedly? -> Isolate the problematic part and post a new question on StackOverflow. |
It is working as expected! However I'm not sure how to programmatically check what the current Scheduler is. So, I wanted to run it by you if I indeed have understood the logic correctly! |
https://stackoverflow.com/questions/50075574/doonsubscribe-gets-called-on-main-thread |
Hi, I am using RxJava 2.1.1. I thought I knew how
subscribeOn
works, but sometimes I still have some doubts about it.As far as I know, for
subscribeOn
it doesn't metter the position where you use it (in the chain).Assuming that I am executing this code from my MAIN THREAD.
As expected the
doOnSubscribe()
is called on the NEW THREAD, because ofsubscribeOn(Schedulers.newThread())
But, if I call
subscribeOn
beforedoOnSubscribe
the result will be different:Now the
doOnSubscirbe()
seems to be executed in the MAIN THREAD, regardless ofsubscribeOn(Schedulers.newThread())
.Why is this happening?
The text was updated successfully, but these errors were encountered: