Last active
November 21, 2019 08:40
-
-
Save zzdjk6/7df1ace324e977148cf95b3cb9c4a0ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Selectors | |
// Select the whole loading state object | |
export const selectLoadingState = (state: RootState) => state.ui.loading; | |
// Select whether a given routine is loading | |
export const selectLoading = (routineType: string) => { | |
return createSelector([selectLoadingState], (state: LoadingState) => { | |
return !!state[routineType]; | |
}); | |
}; | |
// Select whether any routine is loading | |
export const selectAnyLoading = createSelector([selectLoadingState], (state: LoadingState) => { | |
return Object.values(state).some(val => val); | |
}); | |
// Select whether a given set of routines are loading | |
export const selectSomeLoading = (routineTypes: Array<string>) => { | |
return createSelector([selectLoadingState], (state: LoadingState) => { | |
return routineTypes.some(routineType => state[routineType]); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment