tkez
04/08/2021, 11:08 AMprivate val job = SupervisorJob()
private val scope = CoroutineScope(<http://Dispatchers.IO|Dispatchers.IO> + job)
Dominaezzz
04/08/2021, 11:31 AMAdam Powell
04/08/2021, 1:07 PMAdam Powell
04/08/2021, 1:07 PMAdam Powell
04/08/2021, 1:09 PMAdam Powell
04/08/2021, 1:11 PMAdam Powell
04/08/2021, 1:14 PMTODO
to come back and work out a more appropriate scope once you know more about the problem after initial prototyping. There are exceptions but they are rare.tkez
04/08/2021, 1:17 PMAdam Powell
04/08/2021, 1:31 PMval scope = CoroutineScope(context + Job(context[Job]))
scope.launch { ... }
// Later...
scope.cancel()
Vs.
val job = GlobalScope.launch(context) { ... }
// Later...
job.cancel()
The latter is still making use of controlled scoping via the input parent context
and the returned job from the launch, it's just less fiddly.Adam Powell
04/08/2021, 1:33 PMAdam Powell
04/08/2021, 1:33 PMtkez
04/08/2021, 3:21 PM