Skip to content

Commit

Permalink
feat: add selectActionsPendingByPrefix selector
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbodnar committed Jan 25, 2022
1 parent a0fb43d commit c78c696
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/frontend/src/redux/slices/status/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const SLICE_NAME = 'status';

const getTypes = createParameterSelector((params) => params.types);

const getTypePrefix = createParameterSelector((params) => params.typePrefix);

// Top level selectors
export const selectStatusSlice = (state) => state[SLICE_NAME];

Expand All @@ -20,3 +22,12 @@ export const selectActionsPending = createSelector(
(types, actionStatus) => (typeof types === 'string' ? [types] : types).some((type) => actionStatus[type]?.pending)
);

export const selectActionsPendingByPrefix = createSelector(
[getTypePrefix, selectStatusActionStatus],
(typePrefix, actionStatus) => Object.keys(actionStatus).some((type) => {
if (type.startsWith(typePrefix)) {
return actionStatus[type]?.pending;
}
return false;
})
);

0 comments on commit c78c696

Please sign in to comment.