Reducer
Similiar to React's useReducer hook, this contract defines a reducer that can be used to manage the state of a component. The reducer method is used to reduce an event to a new state and potentially produce a list of effects. This effect can be used to trigger side-effects, outside of the reducer, such as network requests, timers or updating the UI. A reducer should be used to manage the state of a component in a deterministic way (i.e., given the same sequence of events, the reducer should always produce the same state - pure function).
To alter the internal state of a component, callers can use dispatch to emit events. The current state can be consulted using the currentState method.
Parameters
the type of the state managed by the reducer.
the type of the event that triggers a state transition.
the type of the effect emitted by the reducer.