https://kotlinlang.org logo
#android
Title
# android
d

Derek Ellis

07/05/2021, 1:25 PM
Presumably it would be unsafe to launch a coroutine using
lifecycleScope
in an activity's
onDestroy()
since the scope only spans until
onDestroy()
is called, right? What would be a suitable alternative to launch a coroutine to do some kind cleanup job that shouldn't be immediately canceled when the activity is destroyed?
MainScope
?
b

bezrukov

07/05/2021, 2:05 PM
Injectable ApplicationScope should be the best option.
MainScope
is a short version for declaring scope with main dispatcher (which will work, but smells).
🙏 2