Hello everyone. In according to documentation we m...
# coroutines
f
Hello everyone. In according to documentation we must to cancel a scope when we do not need more of it.
Copy code
class MyAndroidActivity {
    private val scope = MainScope()

    override fun onDestroy() {
        super.onDestroy()
        scope.cancel()
    }
}
Out of curiosity, what happen if I do not call cancel on onDestroy()??
k
You would potentially leak concurrently running coroutines rather than cleaning them up.
f
Even If the application is closed??
k
if the process is killed, then your concurrent tasks would be killed as well. But if your activity is killed but your app process is still alive you’d leak concurrent takss
f
ahhh ok make sense...thank you so much