I might have missed this before or in the document...
# coroutines
a
I might have missed this before or in the documentation, but are there best practises to handle the new CorotuineScope in fragments (in particular where to attach and cancel an instance of a Job)? Are onAttach/onDetach of the parent activity a good choice? Probably it's more a question for the Android channel, but i've posted here because it is coroutine-related
l
a
thank you for your message. I've read that, but i don't want a dependency on the android architecture components and the lifecycle first, and second i was more interested in a discussion about pros and cons of different choices from a design perspective, instead of a pre-made solution. I see couple of options myself, but i would like to know more about different point of view about this
g
Lifecycle is part of support library
In case of Fragment you need 2 scopes, one for fragment with lifecycle of a fragment and one with lifecyle of a view. We do this with our own solution, which is very similar to new CoroutineScope. Of course you need this only if you need both, in some cases one is enough
👍 1
l
@acando86 It's quite weird to use experimental coroutines, and at the same time, not use lifecycles which are part of the support library/AndroidX…
g
But lifecycle part of support library now, very few application don't use at least support library v4 or new androidx core