Skip to content

Instantly share code, notes, and snippets.

@asherccohen
Created July 26, 2019 11:16
Show Gist options
  • Save asherccohen/fc745663232d7a4d27a6c7c5bedd3150 to your computer and use it in GitHub Desktop.
Save asherccohen/fc745663232d7a4d27a6c7c5bedd3150 to your computer and use it in GitHub Desktop.
LoadingSelector
export const loadingSelector = (state, actions) => {
const types = actions.map(type => {
const matches = /(.*)_(REQUEST|SUCCESS|FAILURE)/.exec(type);
if (!matches) return type;
const [, requestName] = matches;
return requestName;
});
return types.some(action => state.fetching[action]);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment