/** * @internal * States of a data load. */ export type DataState = DataLoadingState | DataErrorState | DataSuccessState; /** * @internal * State of data loading. */ export type DataLoadingState = { /** Whether the data is loading */ isLoading: true; /** Whether the data load has failed */ isError: false; /** Whether the data load has succeeded */ isSuccess: false; /** The error if any occurred */ error: undefined; /** The result data if the load has succeeded */ data: Data | undefined; /** The status of the data load */ status: 'loading'; }; /** * @internal * State of a data load that has failed. */ export type DataErrorState = { /** Whether the data is loading */ isLoading: false; /** Whether the data load has failed */ isError: true; /** Whether the data load has succeeded */ isSuccess: false; /** The error if any occurred */ error: Error; /** The result data if the load has succeeded */ data: undefined; /** The status of the data load */ status: 'error'; }; /** * @internal * State of a data load that has succeeded. */ export type DataSuccessState = { /** Whether the data is loading */ isLoading: false; /** Whether the data load has failed */ isError: false; /** Whether the data load has succeeded */ isSuccess: true; /** The error if any occurred */ error: undefined; /** The result data if the load has succeeded */ data: Data; /** The status of the data load */ status: 'success'; }; /** * @internal */ export type DataLoadAction = { type: 'loading'; } | { type: 'success'; data: Data; } | { type: 'error'; error: Error; }; /** * @internal */ export declare function dataLoadStateReducer(state: DataState, action: DataLoadAction): DataState;