TrackedDataResult

type TrackedDataResult<T> = object;

Reactive state for tracked data managed by useTrackedData.

Lifecycle: starts at loading (or disabled when the spec is null) and fires both the initial RPC request and the subscription on mount; transitions to loaded on the first value (from either source — the underlying store slot-dedupes so out-of-order arrivals never regress) or error on failure. refresh() re-runs the whole pair — while a refresh is in flight, status returns to loading and the stale data and/or error from the prior outcome remain populated (stale-while-revalidate).

Type Parameters

Type ParameterDescription
TThe unified item type held by the store, produced by the two mappers in the spec.

Properties

data

data: SolanaRpcResponse<T> | undefined;

The latest value, slot-deduped across the initial RPC and the subscription, exactly as the underlying kit primitive emits it: a SolanaRpcResponse<T> envelope ({ context: { slot }, value }). The primitive guarantees the envelope shape, so callers can read data.value and data.context.slot directly without a runtime check. undefined on the first load and while disabled. On loading after a prior outcome, on error, and on a subsequent refresh, holds the last received envelope so UIs can show stale data rather than flashing to blank.


error

error: unknown;

Error from either source, or undefined. Only the first error per connection window is captured (the underlying store drops subsequent errors until the next refresh() / connect). On loading after a prior error, holds the stale error so UIs can keep showing the failure context while the refresh is in flight. A subsequent loaded clears it.


refresh

refresh: (options?) => void;

Re-run both the initial RPC request and the subscription. By default each call mints a fresh signal from getAbortSignal (if configured) and threads it through the underlying store's withSignal(signal).connect(). Pass { abortSignal } to override the configured factory for just this attempt. Pass { abortSignal: undefined } to opt out of the factory entirely for this attempt and run with no caller-provided signal.

Stable reference. Safe to put in onClick handlers or effect deps — typically wired up to a "Refresh" or "Retry" button. Calls store.connect() under the hood, so it always (re)runs the pair regardless of current status; the bridge transitions back through loading while preserving stale data and error.

Parameters

ParameterType
options?{ abortSignal?: AbortSignal; }
options.abortSignal?AbortSignal

Returns

void


status

status: "disabled" | "error" | "loaded" | "loading";

Lifecycle status as a discriminated string:

  • loading: an attempt is in progress. On the first attempt, data and error are undefined. After a refresh, data and error hold the last known values from the previous attempt (stale-while-revalidate).
  • loaded: a value has arrived from either source and error is undefined.
  • error: the attempt failed; data holds the last known value (if any).
  • disabled: spec was null — no work was started.

On this page