StoreSpec<R extends string, S extends Record<R, any>, EM extends EventMapBase>

type
types.ts:459

Store configuration object passed to the Store constructor or createStore.

Type parameters

NameTypeDescription
Rextends stringReducer name union (string literal union).
Sextends Record<R, any>State record keyed by R.
EMextends EventMapBaseEvent map.

Properties

NameTypeDescription
dedupWindowMs?numberTime window in milliseconds for **content-based** event deduplication. When greater than 0, events with identical fingerprints (channel + type + serialized payload) within this window are treated as duplicates and skipped. **Off by default.** Content-based dedup can silently drop legitimate rapid-fire identical events (double-clicks, repeated +1, sliders emitting the same value), so it is opt-in. To safely coalesce a *specific* re-fired emit (e.g. React Strict Mode), prefer the per-emit EmitOptions.dedupKey.
devtools?{ allowReplay?: boolean }DevTools configuration options.
effects?EffectSpec<DeepReadonly<S>, EM>[]Optional side-effect handlers registered at construction time. Runs after reducers for every propagated event.
idFactory?() => stringGenerates the id for each emitted event. Defaults to crypto.randomUUID().
maxReduceDepth?numberMaximum causal depth of an event chain before the store refuses to extend it.
maxTransitionsPerDrain?numberMaximum number of events one synchronous drain will process before refusing more.
middleware?MiddlewareInput<DeepReadonly<S>, EM>[]Middleware chain executed before reducers/effects. Accepts either functions (legacy) or MiddlewareSpec objects (recommended). If any middleware returns false (or resolves to false), the event will not propagate.
namestringStore name (used by DevTools to identify the instance).
onCascade?(info: CascadeInfo<EM>) => voidCalled when a ceiling is breached, instead of throwing.
onEffectError?(error: unknown, event: EventUnion<EM>) => voidCalled when an effect throws or its returned promise rejects.
onReducerError?(error: unknown, event: EventUnion<EM>, slice: string) => voidInvoked when a reducer throws.
onRejected?(rejection: Rejection, event: EventUnion<EM>, slice: string) => voidCalled when a reducer refuses a write by returning Rejected.
reducerRecord<R, ReducerSpec<S[R], EM>>Map of slice name → reducer spec. Each entry declares initial state, the reducer function, and the event targeting.