ReducerSpec<S = any, EM extends EventMapBase = EventMapBase>
interfaceOne reducer's definition blob (stateful event consumer).
Use
when for event targeting. An earlier events array was removed; this remark
outlived it and described a property that no longer exists.
**A reducer receives exactly one slice and returns exactly one slice.** state here is this
reducer's own slice, not the store's state, and the value returned is written back only under
this reducer's name. There is no path to a sibling: the reducer is handed no getState, no
store reference, and no second argument beyond the event, and returning a whole-store-shaped
object writes nothing extra because the commit is keyed by the name the reducer was mounted
under.
So cross-slice isolation is a **framework guarantee, not a convention**. There is no second
writer to a slice and therefore no intra-slice authorisation question, only the ordinary
question of whether this reducer's own code is correct. The one cross-slice effect available is
a Rejection, which refuses the whole event rather than writing anywhere.Type parameters
| Name | Type | Description |
|---|---|---|
S | – | State managed by this reducer. |
EM | extends EventMapBase | Event map. |
Properties
| Name | Type | Description |
|---|---|---|
meta? | EventConsumerMeta<"reducer"> | Optional metadata for debugging tools and DevTools integration. |
reducer | ReducerFunction<S, EM> | Pure reducer function: (state, event) => nextState, where state is this reducer's slice
and the return value replaces that slice and nothing else. |
state | S | Initial state for this reducer's own slice. |
when? | ExactWhen<EM> | Event targeting: one of the exact forms of the When matcher. |