I'm just migrating to new scoped coroutines. In on...
# coroutines
k
I'm just migrating to new scoped coroutines. In one case, I'm inside a
Fragment
which implements
CoroutineScope
. The default cancellation behavior is to cancel in
onDestroy
. But one specific coroutine I want to cancel on a different event, e.g. in
onDetach
. Should I create a nested scope or should I just manually cancel the coroutine when the event happens?
k
Just manually cancelling
onDetach
sounds simple enough. Except this is a recurring behavior, I’d keep things simple 🙂
g
We use own scope for both lifecycles: 1 for fragment, 1 for view. But only if you need both, sometimes view is enough
2
k
@gildor can you share the implementation for the scopes?
g
As I said this is our own implementation, not based CoroutinesScope (will migrate eventually). But it’s just 2 nested scopes, view scope canceled onDestroyView, created onViewCreated
k
ok thx