will return when the provided suspend block and child coroutines end.
Instead, is there anything that returns immediately when the block returns, cancelling child coroutines? I thought there would be prebuilt builder.
This would be extremely useful on situations like:
Copy code
coroutineScope { // this suspends until someFlow is finished; needs alternative one
val collected = someFlow.shareIn(this, ...)
work(collected)
}
lhwdev
11/15/2021, 6:09 AM
Ideal one to me:
Copy code
(some cool name)Scope { // someFlow.shareIn is cancelled after work is finished and block returns
val collected = someFlow.shareIn(this, ...)
work(collected)
}
n
Nick Allen
11/15/2021, 6:47 AM
I think you can just call
coroutineContext.cancelChildren
when done.
I’ve never needed such a function. Generally using