Skip to content

Commit

Permalink
feat: add selectActionsPending selector
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinbodnar committed Jan 25, 2022
1 parent d94f941 commit 323dd67
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/frontend/src/redux/slices/status/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { createSelector } from "reselect";

import createParameterSelector from '../createParameterSelector';

const SLICE_NAME = 'status';

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

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

Expand All @@ -10,3 +14,9 @@ export const selectStatusMainLoader = createSelector(selectStatusSlice, (status)
export const selectStatusLocalAlert = createSelector(selectStatusSlice, (status) => status.localAlert || {});

export const selectStatusActionStatus = createSelector(selectStatusSlice, (status) => status.actionStatus || []);

export const selectActionsPending = createSelector(
[getTypes, selectStatusActionStatus],
(types, actionStatus) => (typeof types === 'string' ? [types] : types).some((type) => actionStatus[type]?.pending)
);

0 comments on commit 323dd67

Please sign in to comment.