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,
};
Created
March 6, 2019 08:32
-
-
Save pedpess/6337de63f5c320981b05bd2f2fb9f1d8 to your computer and use it in GitHub Desktop.
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