mingkangpan
01/27/2020, 1:49 PMlaunch(Dispatchers.Unconfined)
and
launch(start = CoroutineStart.UNDISPATCHED)
?
afaiu both will excute job immediatley in the same thread right?elizarov
01/27/2020, 1:57 PMmingkangpan
01/27/2020, 2:11 PMmainScope.launch(dispatcher = UNCONFINED) {
ui.update()
val result = retrofit.fetchResult() //<- retrofit uses non UI thread by default
ui.updateResult() //<- this would beexecuted on non UI thread and eventually lead to crash
}
Dico
01/27/2020, 6:01 PM