https://kotlinlang.org logo
#coroutines
Title
# coroutines
r

rtsketo

01/04/2021, 1:05 PM
How come
Main.immediate
isn't the default dispatcher of
MainScope()
? Is there any disadvantage in using
immediate
?
g

gildor

01/05/2021, 12:11 AM
Yes, behavior of non-immediate dispatcher is more predictable, it always goes through dispatching, so you don't have small behavior changes when start a coroutine from main thread, which cause immediate execution, it may even cause block thread if you do it in a cycle, so you have to call yeild() to force dispatching. Nothing wrong with immediate, but default dispatcher just has less gotchas
❤️ 1
7 Views