RequestResult

type RequestResult<T> = object;

Reactive state for a one-shot request managed by useRequest.

Lifecycle: starts at loading (or disabled when the source is null) and auto-fires on mount; transitions to loaded on success or error on failure. refresh() re-fires the request; while a refresh is in flight after a prior success, status is retrying and data still holds the stale value (stale-while-revalidate).

Type Parameters

Type ParameterDescription
TThe value the underlying request resolves to.

Properties

data

data: T | undefined;

The most recent successful value, or undefined while loading or when disabled.


error

error: unknown;

The error from the most recent failed call, or undefined.


isLoading

isLoading: boolean;

true only on the very first loading state — false during retrying so spinners don't replace stale content.


refresh()

refresh: () => void;

Re-fire the request. Each call starts a fresh attempt with a fresh perRequestSignal. Stable reference.

Returns

void


status

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

Lifecycle status as a discriminated string:

  • loading: first call in flight, no data yet.
  • loaded: call succeeded.
  • error: call failed; refresh() will retry.
  • retrying: re-fire after a prior success or error; data still holds the stale value.
  • disabled: source was null — no request was fired.

On this page