MiddlewareFunction<S = any, EM extends EventMapBase = EventMapBase>
typeMiddleware function: log, guard, or veto an event **synchronously**.
Return true to continue, false to swallow / cancel propagation.
Middleware runs in the synchronous reduce phase (so
getState() is correct
immediately after emit()), and therefore must be synchronous. Perform async
work in effects instead.Definition
type
type MiddlewareFunction<S = any, EM extends EventMapBase = EventMapBase> = (state: S, event: EventUnion<EM>, emit: Emit<EM>) => boolean(state: S, event: EventUnion<EM>, emit: Emit<EM>) => boolean
Type parameters
| Name | Type | Description |
|---|---|---|
S | — | Store state (readonly). |
EM | extends EventMapBase | Event map. |