You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!
The text was updated successfully, but these errors were encountered:
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 callobserveOn(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 withScheduler.from(myThreadExecutor)
) based on my need.Thanks in advance!
The text was updated successfully, but these errors were encountered: