I think, the answers there are great. Take a look at this one with title “TL;DR”
j
Joffrey
10/06/2021, 6:00 PM
You should honestly never use the second approach. Creating a custom
CoroutineScope
goes with controlling its lifecycle. If you create one, you should store it in a variable and cancel it appropriately depending on the lifecycle you want to give it. Otherwise, it's just as bad as
GlobalScope
.
✅ 1
a
Anshulupadhyay03
10/07/2021, 5:40 AM
@Joffrey make sense thanks
u
uli
10/07/2021, 11:16 AM
And Scopes also get garbage collected when not referenced