Am I the only one who thinks it is strange you can...
# coroutines
m
Am I the only one who thinks it is strange you cannot close
MutableSharedFlow
? Seems that cancelling all listeners (so parent scope) is the only way for this program to close 😛 https://pl.kotl.in/EzyFeqARz
j
I was pretty puzzled by it at first, too. But now I kinda understand the reason. Depending on the
started
strategy, the shared flow might stop/re-collect the underlying flow arbitrarily (when using
shareIn
), so the end of the flow is not really the end. To be honest what I miss most is that errors in the source flow don't propagate to the collectors, which I find kinda apalling. I think it would be nice to at least have a built-in way to materialize/dematerialize both errors and completions.
g
built-in way to materialize/dematerialize both errors and completions
https://github.com/Kotlin/kotlinx.coroutines/issues/2092
👍 1
k
Errors don't propagate because it's against the reactive streams spec probably...
j
Correct me if I'm wrong, but I don't believe `SharedFlow`s follow the reactive spec. Apart from a couple specific utilities like
onSubscription
, they pretty much have the same API as regular `Flow`s which do support errors
n
The reasoning is explained here in "Error handling" section: https://github.com/Kotlin/kotlinx.coroutines/issues/2034