Skip to content

RemoteData

RemoteData<E, A> = NotAsked | Loading | Failure<E> | Success<A>

Defined in: Core/RemoteData.ts:23

RemoteData represents the state of an async data fetch. It has four states: NotAsked, Loading, Failure, and Success.

Use RemoteData to model data fetching states explicitly, replacing the common { data: T | null; loading: boolean; error: Error | null } pattern.

E

A

const renderUser = pipe(
  userData,
  RemoteData.match({
    notAsked: () => "Click to load",
    loading: () => "Loading...",
    failure: e => `Error: ${e.message}`,
    success: user => `Hello, ${user.name}!`
  })
);