https://kotlinlang.org logo
#coroutines
Title
# coroutines
p

Pacane

06/11/2020, 4:45 PM
Is there a way to use
supervisorScope
and pass it a parent supervisorJob? From the docs it says I can, but I don't see how I can pass it down
z

Zach Klippenstein (he/him) [MOD]

06/11/2020, 4:52 PM
I haven’t used
supervisorScope
, but i would expect it would follow the pattern of
coroutineScope
in which case the child context’s job will be a child of the parent context’s job.
o

octylFractal

06/11/2020, 4:57 PM
yea, if you want a separate parent (breaking structured concurrency), use
CoroutineScope(SupervisorJob())
, otherwise, it will create a child Job of the
suspend
context that you call it with
b

bdawg.io

06/11/2020, 4:58 PM
supervisorScope { }
as a context function uses the current context to get the parent job always. Otherwise, you can use the
CoroutineScope
factory function passing the desired or new
SupervisorJob
(ie,
CoroutineScope(SupervisorJob())
)
3 Views