Krzysiek Zgondek
09/03/2021, 8:25 PMscope: CoroutineScope
and i have launched a job in that scope:
val context = Dispatchers.Default + CoroutineActionId(id)
val newJob= scope.launch(context) { ... }
given that CoroutineActionId(id)
is an AbstractCoroutineContextElement
how can i reach it having only scope
?
I've tried like this:
val children = scope.coroutineContext[Job]?.children
val activeAction = children?.firstOrNull { it[CoroutineActionId]?.id == id }
if (activeAction != null) {
activeAction.cancelChildren()
activeAction.join()
}
Job
are different than jobs refs returned from launch
but the amount is correctval children = scope.coroutineContext[Job]?.children
list but when i try to get CoroutineActionId
like this
children?.forEach {
println("#state: caid = " + it[CoroutineActionId]?.id)
}
it doesn't existZach Klippenstein (he/him) [MOD]
09/03/2021, 10:57 PMKrzysiek Zgondek
09/04/2021, 12:34 AMZach Klippenstein (he/him) [MOD]
09/04/2021, 12:37 AMKrzysiek Zgondek
09/04/2021, 12:41 AMcoroutineContext
element