ReactiveActionStore
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
Type Parameters
| Type Parameter |
|---|
TArgs extends readonly unknown[] |
TResult |
Properties
dispatch()
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
| Parameter | Type |
|---|---|
...args | TArgs |
Returns
void
See
ReactiveActionStore.dispatchAsync when you need the resolved value or propagated errors.
dispatchAsync()
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
| Parameter | Type |
|---|---|
...args | TArgs |
Returns
Promise<TResult>
getState()
Returns the current state.
Returns
ReactiveActionState<TResult>
reset()
Aborts any in-flight dispatch and resets the state to { status: 'idle' }.
Returns
void
subscribe()
Registers a listener called on every state change. Returns an unsubscribe function.
Parameters
| Parameter | Type |
|---|---|
listener | () => void |
Returns
Returns
void