zak.taccardi
09/10/2020, 8:05 PMCoroutineScope
, what is the idiomatic way to create a child scope?wasyl
09/10/2020, 8:06 PMcoroutineScope { }
zak.taccardi
09/10/2020, 8:08 PM(CoroutineScope) -> CoroutineScope
where the output is a child scopeval globalSdkScope: CoroutineScope
val childScope = globalSdkScope + Job(globalSdkScope.coroutineContext[Job]!!)
Casey Brooks
09/10/2020, 8:18 PMzak.taccardi
09/10/2020, 8:18 PMCasey Brooks
09/10/2020, 8:21 PMzak.taccardi
09/10/2020, 8:21 PMZach Klippenstein (he/him) [MOD]
09/10/2020, 8:45 PMzak.taccardi
09/10/2020, 8:46 PMpublic fun CoroutineScope.newChildScope(
context: CoroutineContext = EmptyCoroutineContext
): CoroutineScope {
val parentScope = this
return parentScope + parentScope.job.newChildJob() + context
}
public fun Job.newChildJob(): Job {
val parentJob = this
return Job(parent = parentJob)
}
gildor
09/10/2020, 11:53 PMzak.taccardi
10/06/2020, 10:18 PMGlobalScope
should never be used, thoughgildor
10/06/2020, 11:35 PM