-
Notifications
You must be signed in to change notification settings - Fork 3k
Shouldn't AndroidSchedulers.mainThread() act as Schedulers.immediate() when already on the main thread? #335
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
Comments
This comes up often with GUI-type schedulers. The problem is with the recursive scheduling aspects of many flows is that they can pin the GUI thread processing one particular sequence and not executing GUI update requests from other sources. By doing this one by one, there is a much higher chance of mixing various actions and keeping the GUI responsive. Besides, doing to much workload on the GUI thread is usually considered a bad thing. What you are suggesting is how Each library can decide what's the reasonable to do and since RxJava is not a framework, you are free to implement your own scheduler (even by copying and modifying an existing one to your needs). Schedulers are one of the things that can live anywhere (unlike instance methods on |
Prior art: #228, JakeWharton/RxBinding#28. If you want something to run synchronously the answer is not schedule and ensure you're already on the main thread. If you are doing something like Also more info here: https://www.youtube.com/watch?v=va1d4MqLUGY |
Im still heavily struggling with this aspect of RxJava. I have a manager class that returns data. It returns it from cache if available, else from network. |
可以这样写: |
或者创建一个类 import android.os.Handler; import java.util.concurrent.Executor; import rx.Scheduler; /**
} ` |
Uh oh!
There was an error while loading. Please reload this page.
This is more a discussion / question then anything else.
Let's take this code as example:
it prints:
If executed on the main thread, wouldn't it be useful to have a way of making it print:
?
I'm thinking about how Loaders works, when you
init()
they immediately return the value if it has already been loaded.The recyclerView is different in this but the old ListView didn't correctly resumed the list if you didn't set your data in the onCreated method of the Activity (if I recall correctly). I remember it resetting to the top.
I wouldn't change the current behavior for backward compatibility, but I'd add a new schedulers working like that if possible.
What do you think? Would it be useful?
The text was updated successfully, but these errors were encountered: