ReactiveState

type ReactiveState<T> = 
  | {
  data: T | undefined;
  error: unknown;
  status: "error";
}
  | {
  data: T | undefined;
  error: unknown;
  status: "loading";
}
  | {
  data: T;
  error: undefined;
  status: "loaded";
}
  | {
  data: undefined;
  error: undefined;
  status: "idle";
};

The lifecycle state of a ReactiveStreamStore as a single snapshot.

  • idle: the store has not yet been connected, or has been reset via `reset()`. Call `connect()` to open the underlying stream.
  • loading: a connection is in progress. data and error are preserved from the previous connection (if any) — stale-while-revalidate UX. A subsequent loaded clears error; a subsequent error replaces it.
  • loaded: a value has been received and no error is active.
  • error: the stream failed. data holds the last known value (or undefined if none ever arrived) and error holds the failure.

Type Parameters

Type Parameter
T

On this page