gildor
09/24/2018, 2:44 PMaaverin
09/25/2018, 9:44 AMdoStuff()
is private
Would you recommend to move to another class and have just a manager
kind of class that will run coroutine in proper dispatcher and do nothing else?gildor
09/25/2018, 9:45 AMaaverin
09/25/2018, 9:45 AMjob
and handle cancelation if necessary, thus it’s not exposed as suspend
gildor
09/25/2018, 9:47 AMmyMethod
that you do not return JobdoStuff
than just GlobalScope.launch and a function that runs and forgetWould you recommend to move to another class and have just aActually, this is one of possible solutions, but even in this case probably it can be somehow improvedkind of class that will run coroutine in proper dispatcher and do nothing elsemanager
aaverin
09/25/2018, 10:18 AMsuspend
then, essentially, only Activity/Fragment would be using dispatchers and would be running coroutines?manager
classwithContext
for services, that have to definitely run in background, like, 3rd party API callsgildor
09/26/2018, 1:05 AMaaverin
09/26/2018, 7:59 AMsubscribeOn
and observeOn
, and once you get the description of those methods – it’s quite easy to see which thread code will be called on, and which thread will subscriber receive the data on.
With coroutines it’s not that easy somehow.gildor
09/26/2018, 8:21 AM