MiddlewareFunction<S = any, EM extends EventMapBase = EventMapBase>

type
types.ts:757

Middleware 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

NameTypeDescription
SStore state (readonly).
EMextends EventMapBaseEvent map.