Skip to content
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

Use of Schedulers on UseCase #302

Open
canemacchina opened this issue May 3, 2020 · 0 comments
Open

Use of Schedulers on UseCase #302

canemacchina opened this issue May 3, 2020 · 0 comments

Comments

@canemacchina
Copy link

canemacchina commented May 3, 2020

Hi,

I was reading your project and there's something regarding the use of Schedulers on UseCase that I don't well understand.

Note that I'm quite new to android programming so please forgive me if I say something terribly wrong! 😅

So, why the UseCase needs a ThreadExecutor for the "backend" computation and a Scheduler to execute the observer? Why not ask for the same type?

I mean, if the reason to ask for a ThreadExecutor is to be free to use whatever executor you want, why the same thing doesn't apply for observeOn? Why can't we ask again for another ThreadExecutor and simply call observeOn(Schedulers.from(executor))?
(Note: I understand that is very simple to refer to the main thread using Schedulers thanks to AndroidSchedulers.mainThread(). There isn't a so simple way to obtain the main ThreadExecutor on Android?)

And why we can't achieve the same result asking for two Schedulers?
I mean, if I want simply use Schedulers.io() as background scheduler, how can I pass it to the UseCase?
If the UseCase was asking for a Scheduler also for subscribeOn, I could pass Schedulers.io() or a custom scheduler (created with Scheduler.from(myThreadExecutor)) based on my need.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant