Pablo12/27/2021, 4:18 PM
is it good to implement the
? Or it's better to create a scope
And use it and cancel it depending on if the view is visible or not (attached/detached). The thing is that I'm doing some things and painting the custom view so I'm using a CoroutineScope for this but I'm afraid that if the CustomView is gone the coroutine is not and then try to do something and crash the app. Have anyone of you faced something similar? I used to inject the lifecycle of the "parent" let's say an
private val scope = MainScope()
and once this is gone the coroutine is cancelled automatically.
interface is like creating my own lifecycle? I've read long time ago that if a view has its own lifecycle I should implement
otherwise there are other ways...
stojan12/27/2021, 4:44 PM
rkeazor12/27/2021, 7:06 PM
Nick Allen12/27/2021, 7:36 PM
. https://proandroiddev.com/why-your-class-probably-shouldnt-implement-coroutinescope-eb34f722e510 https://kt.academy/article/cc-constructing-scope