Estás leyendo la documentación de 0.9. La versión más reciente es 0.10. Leer esta página en 0.10 →
La referencia de la API está disponible solo en inglés por ahora.

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

type
types.ts:533

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). An event stops propagating only when a middleware returns an explicit false, or throws. Returning nothing allows it. Middleware is synchronous: a Promise is not false, so it cannot veto.
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.
onSubscriberError?(error: unknown, event: EventUnion<EM>, phase: NotifiedPhase) => voidCalled when an onEvent subscriber throws, or rejects.
reducerRecord<R, ReducerSpec<S[R], EM>>Map of slice name → reducer spec. Each entry declares initial state, the reducer function, and the event targeting.