https://kotlinlang.org logo
d

Daniel

10/16/2020, 10:50 AM
How can I create a sub-scope of a CoroutineScope? I'm looking for something like
Copy code
val parentScope: CoroutineScope
val childScope = parentScope.something()
I want childScope to be cancelled if parentScope is, but for parentScope not to be cancelled if childScope is
m

Marc Knaup

10/16/2020, 11:01 AM
CoroutineScope(parentScope.coroutineContext + SupervisorJob())
or
Copy code
supervisorScope { your child code() }
d

Daniel

10/16/2020, 11:49 AM
Thank you
10 Views