What should I use instead of `GlobalScope` in Kotl...
# coroutines
t
What should I use instead of
GlobalScope
in Kotlin/JS? I can't seem to find any other `CoroutineScope`s to use...
c
GlobalScope is discouraged, because it’s better to create your own scope whose lifecycle you control. For example,
MainScope()
or
CoroutineScope(Dispatchers.Default + SupervisorJob())
t
Is that because if I write
GlobalScope.launch { ... }
the resulting job won't get canceled? Is that because...
GlobalScope
never canceled?
k
Similar to
async
but returns a promise which can be awaited in js
c
Is that because...
GlobalScope
never canceled?
Yes
thank you color 1