lhwdev
11/15/2021, 6:09 AMcoroutineScope {} 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:
coroutineScope { // this suspends until someFlow is finished; needs alternative one
val collected = someFlow.shareIn(this, ...)
work(collected)
}lhwdev
11/15/2021, 6:09 AM(some cool name)Scope { // someFlow.shareIn is cancelled after work is finished and block returns
val collected = someFlow.shareIn(this, ...)
work(collected)
}Nick Allen
11/15/2021, 6:47 AMcoroutineContext.cancelChildren when done.
I’ve never needed such a function. Generally using WhileSubscribed() is enough to avoid forever running shared flows.