Pablo
12/27/2021, 4:18 PMConstraintLayout
is it good to implement the CoroutineScope
? Or it's better to create a scope
private val scope = MainScope()
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 Activity
or a Fragment
and once this is gone the coroutine is cancelled automatically.Pablo
12/27/2021, 4:20 PMCoroutineScope
interface is like creating my own lifecycle? I've read long time ago that if a view has its own lifecycle I should implement CoroutineScope
otherwise there are other ways...stojan
12/27/2021, 4:44 PMrkeazor
12/27/2021, 7:06 PMNick Allen
12/27/2021, 7:36 PMCoroutineScope
.
https://proandroiddev.com/why-your-class-probably-shouldnt-implement-coroutinescope-eb34f722e510
https://kt.academy/article/cc-constructing-scope