Hey. I was wondering why `fold` and `reduce` on `F...
# coroutines
a
Hey. I was wondering why
fold
and
reduce
on
Flow
are terminal operators. I imagine collecting a hot flow, e.g.
SharedFlow
and applying
reduce
operator to accumulate the observed values as they appear. IMO it should simply return another
Flow
just like
map
operator. Do you know of any alternatives to what I imagined?
e
reduce returns a single value, how can that not be terminal?
perhaps you are thinking of runningFold?
a
You're right. I imagined the operator would emit the accumulator every time instead of a single value 🤔
Yes, I think I was looking for
runningFold
. Thanks a lot.