This implements fold, which is initialized with an initial state and a
function that takes the current state and next element, outputting the
next state.
Unlike scan, fold does not emit each state downstream, instead only
emitting a single element when upstream completes.
Additionally, this fixes a bug in Fused where logic could receive events
even after they emitted a stopped action.
This implements fold, which is initialized with an initial state and a function that takes the current state and next element, outputting the next state.
Unlike scan, fold does not emit each state downstream, instead only emitting a single element when upstream completes.
Additionally, this fixes a bug in Fused where logic could receive events even after they emitted a stopped action.