Method Accum
- Namespace
- SodaFlow
- Assembly
- SodaFlow.dll
Accum<T, TReturn>(Stream<T>, TReturn, Func<T, TReturn, TReturn>)
Accumulate on this stream, outputting the new state each time an event fires.
public static Cell<TReturn> Accum<T, TReturn>(this Stream<T> s, TReturn initialState, Func<T, TReturn, TReturn> f)
Parameters
sStream<T>The stream.
initialStateTReturnThe initial state.
fFunc<T, TReturn, TReturn>Function to apply to update the state. It can make FRP logic or use Sample<T>(Cell<T>), and this is then equivalent to snapshotting the cell with Snapshot<T, TResult>(Stream<T>, Cell<TResult>). Apart from this, the function must be pure.
Returns
- Cell<TReturn>
A cell holding the accumulated state of this stream.
Type Parameters
TThe type of the stream.
TReturnThe type of the accumulated state.