suspend fun main() {
coroutineScope {
flowOf<Unit>().shareIn(this, SharingStarted.WhileSubscribed())
}
}
https://pl.kotl.in/gaJVXPMWr = Evaluation stopped while it's taking too long️. Why? The child coroutine of shareIn should, according to docs, never start
Nick Williams
04/13/2022, 11:59 AM
ok looking at the source of shareIn both Lazily and WhileSubscribed will block forever until the first subscriber appears
Nick Williams
04/13/2022, 12:00 PM
Eagerly would complete
e
ephemient
04/13/2022, 12:06 PM
also shareIn always has to create a new child job (even for WhenStarted because it needs to live independently of the subscribers), which it can't close itself
n
Nick Williams
04/13/2022, 12:09 PM
thanks, what pattern do you suggest to create a scope that doesnt wait for its child when it completes? A kind of finiteCoroutineScope { ... } as coroutineScope { ...; cancel() } feels unnatural to me