Interface: MiddlewareStore\
June 23, 2026 ยท View on GitHub
coaction / api-docs / MiddlewareStore
Interface: MiddlewareStore<T>
Defined in: packages/core/src/interface.ts:164
Semantic alias for middleware-facing stores.
Remarks
Middleware implementations should type their store parameter as MiddlewareStore instead of relying on deprecated patch or trace hooks.
Extends
Store<T>
Type Parameters
T
Properties
apply()
apply: (
state?,patches?) =>void
Defined in: packages/core/src/interface.ts:132
Apply patches to the current state.
Parameters
state?
T
patches?
Patches
Returns
void
Remarks
This is a low-level hook used by transports and middleware. Application code should generally prefer store methods or setState().
Inherited from
destroy()
destroy: () =>
void
Defined in: packages/core/src/interface.ts:111
Tear down the store.
Returns
void
Remarks
destroy() is idempotent. It clears subscriptions and disposes any attached transport.
Inherited from
getInitialState()
getInitialState: () =>
T
Defined in: packages/core/src/interface.ts:144
Return the state produced during initialization before later mutations.
Returns
T
Inherited from
getPureState()
getPureState: () =>
T
Defined in: packages/core/src/interface.ts:140
Return the current state without methods or getters.
Returns
T
Remarks
Useful for serialization, inspection, or tests that only care about raw data.
Inherited from
getState()
getState: () =>
T
Defined in: packages/core/src/interface.ts:97
Read the current state object.
Returns
T
Remarks
The returned object includes methods and getters. Methods destructured from this object continue to execute against the latest store state.
Inherited from
isSliceStore
isSliceStore:
boolean
Defined in: packages/core/src/interface.ts:124
Whether createState was interpreted as a slices object.
Inherited from
name
name:
string
Defined in: packages/core/src/interface.ts:69
The name of the store.
Inherited from
patch()?
optionalpatch: (option) =>PatchTransform
Defined in: packages/core/src/interface.ts:149
Parameters
option
Returns
Deprecated
Middleware compatibility hook. Prefer typing middleware stores with MiddlewareStore.
Inherited from
setState()
setState: (
next,updater?) =>void
Defined in: packages/core/src/interface.ts:78
Mutate the current state.
Parameters
next
The next partial state, or an updater that mutates a draft.
DeepPartial<T> | (draft) => any | null
updater?
(next) => [] | [T, Patches, Patches]
Low-level updater hook used by transports and middleware integrations.
Returns
void
Remarks
Pass a deep-partial object to merge fields, or pass an updater to edit a Mutative draft. Passing null is a no-op. Client-side shared stores intentionally reject direct setState() calls; trigger a store method instead.
Inherited from
share?
optionalshare:false|"main"|"client"
Defined in: packages/core/src/interface.ts:116
Indicates whether the store is local, the main shared store, or a client mirror of a shared store.
Inherited from
subscribe()
subscribe: (
listener) => () =>void
Defined in: packages/core/src/interface.ts:103
Subscribe to state changes.
Parameters
listener
Listener
Returns
A function that removes the listener.
():
void
Returns
void
Inherited from
trace()?
optionaltrace: (options) =>void
Defined in: packages/core/src/interface.ts:154
Parameters
options
Returns
void
Deprecated
Middleware compatibility hook. Prefer typing middleware stores with MiddlewareStore.
Inherited from
transport?
optionaltransport:Transport<any>
Defined in: packages/core/src/interface.ts:120
Transport used to synchronize a shared store between processes or threads.