I have a few subcomponents, each which have a stat...
# coroutines
b
I have a few subcomponents, each which have a state. From the 'parent' component, I want to monitor the state changes of the subcomponents and, if any of them go to an error state, take some action. I was hoping to be able to do a
select
expression in the 'parent' on a set of
StateFlows
from the subcomponents, but I saw
onReceive
isn't directly supported by
StateFlow
. I tried using
produceIn
on the
StateFlow
so I could use
onReceive
, but then I get the most recent state over and over. I looked at using
distinctUntilChanged
on the
StateFlow
, but then saw that has no effect...What should I go with here? I also can't 'miss' a value here, so maybe
StateFlow
is the wrong tool?
SharedFlow
seems to have similar problems. A normal
Channel
does seem to get me the behavior I want, though I do miss the state-variable style of
StateFlow
, though.
Also I lose the 'broadcast' semantics by using
Channel
, which I think I also need. So maybe I'll just implement a 'manual' select-type logic to monitor multiple
SharedFlow
s