Anyone have a suggestion for how to do things like .map and .filter on a StateFlow without converting it to regular Flow object? Or does that just not make much logical sense? I can see how composition like that can throw a wrench into the current value management, but it seems like it’s kind of a miss.
m
Marc Knaup
10/23/2020, 1:28 PM
Does not make sense doing that.
.map
for example will transform the value for one downstream Flow.
But other Flows may work on the original value.
If you want your transformed value to be a state again and be saved, then use
Copy code
originalStateFlow
.map { … }
.stateIn(…)
m
mattinger
10/23/2020, 1:31 PM
Thanks. That’s what i was missing
mattinger
10/23/2020, 1:38 PM
Though i suspect i need a version upgrade for that. we’re currently on 1.3.7, and i don’t expect that 1.3.9 would have new functions. I’m guessing it’s in 1.4.0 which isn’t full release yet