ReactiveActionStore

type ReactiveActionStore<TArgs, TResult> = object;

A framework-agnostic state machine that wraps an async function and exposes a { dispatch, getState, subscribe, reset } contract. Bridges trivially into useSyncExternalStore, Svelte stores, Vue's shallowRef, and similar reactive primitives.

See

createReactiveActionStore

Type Parameters

Type Parameter
TArgs extends readonly unknown[]
TResult

Properties

dispatch()

readonly dispatch: (...args) => void;

Fire-and-forget dispatch. Returns undefined synchronously and never throws — failures surface on state as { status: 'error' }, and superseded or reset()-aborted calls produce no state update. Use from UI event handlers; there's no promise to handle or .catch.

Parameters

ParameterType
...argsTArgs

Returns

void

See

ReactiveActionStore.dispatchAsync when you need the resolved value or propagated errors.


dispatchAsync()

readonly dispatchAsync: (...args) => Promise<TResult>;

Promise-returning dispatch for imperative callers. Resolves with the wrapped function's result on success. Rejects with the thrown error on failure, and with an AbortError when the call is superseded or reset() is invoked — filter those with isAbortError from @solana/promises.

Parameters

ParameterType
...argsTArgs

Returns

Promise<TResult>


getState()

readonly getState: () => ReactiveActionState<TResult>;

Returns the current state.

Returns

ReactiveActionState<TResult>


reset()

readonly reset: () => void;

Aborts any in-flight dispatch and resets the state to { status: 'idle' }.

Returns

void


subscribe()

readonly subscribe: (listener) => () => void;

Registers a listener called on every state change. Returns an unsubscribe function.

Parameters

ParameterType
listener() => void

Returns

(): void;
Returns

void

On this page