17 lines
519 B
TypeScript
17 lines
519 B
TypeScript
/**
|
|
* Declares the state of something a component loads from the API, which
|
|
* `ListState` renders while it isn't loaded.
|
|
*
|
|
* @module
|
|
*/
|
|
|
|
/**
|
|
* Held by a page or hook for what it fetches, as `useFetchState` returns it,
|
|
* and passed to `ListState`. `L` is what the loaded state carries besides its
|
|
* status, as `{ data: T }` for `useFetchState` or a feed's page fields.
|
|
*/
|
|
export type LoadState<L extends object> =
|
|
| { status: "loading" }
|
|
| { status: "error"; error: string }
|
|
| ({ status: "loaded" } & L);
|