Skip to content

Instantly share code, notes, and snippets.

@DmitryEfimenko
Created July 1, 2022 09:03
Show Gist options
  • Select an option

  • Save DmitryEfimenko/43ba2f0a83d0dfa1b49de5c81f1a472a to your computer and use it in GitHub Desktop.

Select an option

Save DmitryEfimenko/43ba2f0a83d0dfa1b49de5c81f1a472a to your computer and use it in GitHub Desktop.
type RemoteData<T = unknown, E = Error> =
| NotAskedState<T>
| LoadingState<T>
| SuccessState<T>
| ErrorState<T, E>;
export interface LoadingState<T = unknown> {
readonly state: 'loading';
readonly isLoading: true;
readonly value?: T;
}
export interface SuccessState<T> {
readonly state: 'success';
readonly isLoading: false;
readonly value: T;
}
// etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment