MiddlewareSpec<S = any, EM extends EventMapBase = EventMapBase>
interfaceMiddleware specification with optional event targeting and metadata.
- If
when is omitted, middleware receives ALL events.
- Use when to filter which events the middleware processes.
- Middleware runs BEFORE reducers and can cancel event propagation.Type parameters
| Name | Type | Description |
|---|---|---|
S | — | Store state (readonly). |
EM | extends EventMapBase | Event map. |
Properties
| Name | Type | Description |
|---|---|---|
meta? | EventConsumerMeta<"middleware"> | Optional metadata for debugging tools and DevTools integration. |
middleware | MiddlewareFunction<S, EM> | Middleware function: (state, event, emit) => boolean (synchronous).
Return false to cancel event propagation. |
when? | When<EM> | Event targeting (optional). If omitted, middleware receives ALL events. |