Reducer<S, EM extends EventMapBase = EventMapBase>
classThin wrapper around a pure reducer function (stateful event consumer):
given a state S and an event (from `EventUnion<EM>`),
returns the next state S.
- The reducer function is expected to be **pure** and **side-effect free**.
- Use this class when you want to pass a reducer around as a value, or to
unify the reducer interface across the core API.
Type parameters
| Name | Type | Description |
|---|---|---|
S | — | State shape handled by this reducer. |
EM | extends EventMapBase | Event map describing the valid event keys and payload types. |
Constructor
constructor
Creates a new Reducer from a pure reducer function.
Methods
reduce
Applies the reducer to produce the next state.