Is there a way to use `supervisorScope` and pass i...
# coroutines
p
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
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
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
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())
)