import ApiError from './ApiError';
interface NotFetched {
kind: 'NotFetched'
}
interface IsFetching {
kind: 'IsFetching'
}
interface Fetched<Data> {
kind: 'Fetched',
data: Data
}
interface ErrorFetching {
kind: 'ErrorFetching',
// ApiError returns an ErrorCode type of all error codes that your API could return e.g. 'RESOURCE_NOT_FOUND'
error?: ApiError.ErrorCode
}
type RemoteData<Data> =
| NotFetched
| IsFetching
| Fetched<Data>
| ErrorFetching
;
export {
NotFetched,
IsFetching,
Fetched,
ErrorFetching,
RemoteData,
};
RemoteData example from Elm to use in TS
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment