Last active
May 11, 2019 16:33
-
-
Save alex-okrushko/886ad72a9f1a768bf6dd2dea17fdcc98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const enum LoadingState { | |
INIT = 'INIT', | |
LOADING = 'LOADING', | |
LOADED = 'LOADED', | |
} | |
export interface ErrorState { | |
errorMsg: string; | |
} | |
export type CallState = LoadingState | ErrorState; | |
// Helper function to extract error, if there is one. | |
export function getError(callState: CallState): string | null { | |
if ((callState as ErrorState).errorMsg !== undefined) { | |
return (callState as ErrorState).errorMsg; | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment