signal-desktop/ts/util/loadable.ts

16 lines
370 B
TypeScript
Raw Normal View History

2021-12-16 15:02:22 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export enum LoadingState {
Loading,
Loaded,
LoadFailed,
}
export type Loadable<ValueT, ErrorT = unknown> =
| {
loadingState: LoadingState.Loading;
}
| { loadingState: LoadingState.Loaded; value: ValueT }
| { loadingState: LoadingState.LoadFailed; error: ErrorT };