Interface: MiddlewareStore\

June 23, 2026 ยท View on GitHub

coaction


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

Type Parameters

T

T extends ISlices = ISlices

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

Store.apply


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

Store.destroy


getInitialState()

getInitialState: () => T

Defined in: packages/core/src/interface.ts:144

Return the state produced during initialization before later mutations.

Returns

T

Inherited from

Store.getInitialState


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

Store.getPureState


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

Store.getState


isSliceStore

isSliceStore: boolean

Defined in: packages/core/src/interface.ts:124

Whether createState was interpreted as a slices object.

Inherited from

Store.isSliceStore


name

name: string

Defined in: packages/core/src/interface.ts:69

The name of the store.

Inherited from

Store.name


patch()?

optional patch: (option) => PatchTransform

Defined in: packages/core/src/interface.ts:149

Parameters

option

PatchTransform

Returns

PatchTransform

Deprecated

Middleware compatibility hook. Prefer typing middleware stores with MiddlewareStore.

Inherited from

Store.patch


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

Store.setState


share?

optional share: 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

Store.share


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

Store.subscribe


trace()?

optional trace: (options) => void

Defined in: packages/core/src/interface.ts:154

Parameters

options

StoreTraceEvent

Returns

void

Deprecated

Middleware compatibility hook. Prefer typing middleware stores with MiddlewareStore.

Inherited from

Store.trace


transport?

optional transport: Transport<any>

Defined in: packages/core/src/interface.ts:120

Transport used to synchronize a shared store between processes or threads.

Inherited from

Store.transport