https://kotlinlang.org logo
#flow
Title
# flow
c

Chris Fillmore

07/20/2021, 8:59 PM
Hi folks. Question about using SharedFlow: sometimes I want to apply
filter
or
map
, but these return regular `Flow`s, but I still want to use a SharedFlow. I know I can call
stateIn
or
shareIn
to turn them back into a StateFlow/SharedFlow, but this requires that I pass some arguments, when what I really want is for the same SharedFlow I had before, except with these filters/maps applied. Am I missing something? Is there a better way to map/filter a SharedFlow?
w

wasyl

07/20/2021, 10:00 PM
What's some example use case you need this for?
e

ephemient

07/20/2021, 10:23 PM
if your transformations are stateless, then it shouldn't matter how many times the resulting flow is subscribed, even if it's not a "StateFlow". if they're stateful, you should probably declare what dispatcher they run on anyway…
c

Chris Fillmore

07/21/2021, 12:53 AM
Thanks for responding! Sorry I realize my question is more about
StateFlow
specifically, since I have some code which accesses
value
directly. But, as it turns out, when I tried to write some example describing what I’d like to do, I realized that it did not make sense to filter/map a state flow into another state flow. So thanks anyhow!
👍 1
6 Views