Laura de la rosa
08/29/2019, 2:37 PMDominaezzz
08/29/2019, 2:38 PMDominaezzz
08/29/2019, 2:38 PMlaunch vs async.Dominaezzz
08/29/2019, 2:39 PMGlobalScope vs CoroutineScope(context)Dominaezzz
08/29/2019, 2:40 PMcontext.Laura de la rosa
08/29/2019, 2:40 PMGlobalScope vs CoroutineScope(context)Dominaezzz
08/29/2019, 2:42 PMDominaezzz
08/29/2019, 2:43 PMcontext.Laura de la rosa
08/29/2019, 2:46 PMstreetsofboston
08/29/2019, 2:47 PMwithContext, etc), and it has no Job (ie. You can’t cancel a GlobalScope, for example)Laura de la rosa
08/29/2019, 2:47 PMstreetsofboston
08/29/2019, 2:48 PMval scope = CoroutineScope(), it will add a Job() to its coroutineContext, by defaultDominaezzz
08/29/2019, 2:49 PMstreetsofboston
08/29/2019, 2:50 PMSupervisorJob() if needed. But the default providing of Job() is a good default.
But using the factory method CoroutineScope(...), it always will have a Job, which means it is cancelable, whereas GlobalScope isn’tLaura de la rosa
08/29/2019, 2:52 PMstreetsofboston
08/29/2019, 2:52 PMscope.cancel() at some point, yes.streetsofboston
08/29/2019, 2:53 PMLaura de la rosa
08/29/2019, 2:53 PMLaura de la rosa
08/29/2019, 2:53 PMLaura de la rosa
08/29/2019, 2:53 PMstreetsofboston
08/29/2019, 2:54 PMLaura de la rosa
08/29/2019, 2:55 PMGlobalScope?streetsofboston
08/29/2019, 2:55 PMstreetsofboston
08/29/2019, 2:56 PMGlobalScope.launch {
withContext(dispatcher) {
...
}
}Laura de la rosa
08/29/2019, 2:57 PMstreetsofboston
08/29/2019, 2:57 PMLaura de la rosa
08/29/2019, 2:58 PMstreetsofboston
08/29/2019, 2:59 PMLaura de la rosa
08/29/2019, 3:00 PMstreetsofboston
08/29/2019, 3:00 PMDominaezzz
08/29/2019, 3:01 PMstreetsofboston
08/29/2019, 3:01 PMstreetsofboston
08/29/2019, 3:02 PMZach Klippenstein (he/him) [MOD]
08/29/2019, 3:25 PMbasher
08/29/2019, 3:31 PM