val numberFlow = MutableStateFlow<Int>(0)
val lessThanZero = numberFlow.filter { it < 0 }
// Suppose for a moment that filter/map could return a StateFlow, how would the below work:
val currentValue = lessThanZero.value
// What's the value of currentValue?
🙏 1
a
Alex
09/01/2021, 8:11 AM
@Chris Fillmore yeah, for
.filter
this is easy, but for
map
its harder to see, since map will always return a value.
map
being able to suspend solves the question because then it might suspend for a while (on first submision) in which no value is present in the resulting stateflow, which is not allowed.