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

nwh

11/05/2018, 9:38 PM
Is there any "guide" on knowing which scope to pick when launching a coroutine? I'm not sure what exactly I should be basing that decision off of. For example, if I'm launching something that isn't directly relevant to a lifecycle, should I only use
GlobalScope
, or should I use the most localized scope I can, just so the processes stay organized?
d

Dico

11/05/2018, 10:28 PM
Make that decision based on the parent the coroutine should have, such that errors that occur cancel the right parent and vice versa, and which dispatcher it should use. It depends on the context.
3 Views