-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from daiscog/typing-improvements
Adjust typing for improved type guard ergonomics.
- Loading branch information
Showing
5 changed files
with
25 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
import { | ||
ErrorState, | ||
HttpRequestState, | ||
LoadedState, | ||
LoadingState, | ||
} from './model'; | ||
import { ErrorState, LoadedState, LoadingState } from './model'; | ||
|
||
export function isLoadingState<T>( | ||
state?: HttpRequestState<T> | ||
state?: LoadingState<T> | ErrorState<unknown> | LoadedState<unknown> | ||
): state is LoadingState<T> { | ||
return !!state && state.isLoading; | ||
} | ||
|
||
export function isLoadedState<T>( | ||
state?: HttpRequestState<T> | ||
state?: LoadedState<T> | LoadingState<unknown> | ErrorState<unknown> | ||
): state is LoadedState<T> { | ||
return !!state && !state.isLoading && !state.error; | ||
} | ||
|
||
export function isErrorState<T>( | ||
state?: HttpRequestState<T> | ||
state?: ErrorState<T> | LoadedState<unknown> | LoadingState<unknown> | ||
): state is ErrorState<T> { | ||
return !!state && !state.isLoading && !!state.error; | ||
} |