黄舟2017-04-17 17:53:12
doOnNext will be called before onNext, which is usually some preparation work. I don’t know why you write the same code in onNext and doOnNext..... Also, you should be using retrofit. I don’t know if Retrofit’s Build has it. That’s right, so it’s possible that the User information is not obtained at all. RxJava is a library specifically designed to handle asynchronous streams, so there is no “asynchronous problem” you mentioned
How to handle it depends on your business needs. For example, you will make a request to get the local weather based on the user's region; or filter out certain users who are younger than 18 years old
大家讲道理2017-04-17 17:53:12
In asynchronous programming, after the code is executed, it is equivalent to scheduling a task. The task may not have started yet. The callback will not be executed until the asynchronous task is completed to get the real return value
For example:
It’s time to go to bed. Tell your wife that I want to eat egg pancakes tomorrow morning and call me when she’s ready.
When you finish saying this, where are the egg pancakes? What about egg pancakes?
Obviously it will have to wait until tomorrow morning