Skip to content

Commit

Permalink
Update state_selectors.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
jucasoft authored Jan 22, 2024
1 parent 3b3da75 commit 651a7df
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions projects/ngrx-entity-crud/src/lib/state_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ export function getCrudBaseSelectors<T, V>(
const selectLastCriteria: MemoizedSelector<V, ICriteria> = createSelector(selectState, getLastCriteria);
const selectResponses: MemoizedSelector<V, OptResponse<T>[]> = createSelector(selectState, getRespones);

const selectItemSelected: MemoizedSelector<V, T> = createSelector(selectState, getItemSelected) as MemoizedSelector<V, T>;

return {
selectError,
selectIsLoading,
selectIsLoaded,
selectLastCriteria,
selectResponses,
selectItemSelected
};
}

Expand All @@ -40,7 +43,8 @@ export function getSingeCrudSelectors<T, V>(
selectIsLoading,
selectIsLoaded,
selectLastCriteria,
selectResponses
selectResponses,
selectItemSelected
} = getCrudBaseSelectors(selectState);

const selectItem: MemoizedSelector<V, T> = createSelector(selectState, getItem) as MemoizedSelector<V, T>
Expand All @@ -50,7 +54,8 @@ export function getSingeCrudSelectors<T, V>(
selectIsLoading,
selectIsLoaded,
selectLastCriteria,
selectResponses
selectResponses,
selectItemSelected
};
}

Expand All @@ -64,7 +69,6 @@ export function createCrudSelectorsFactory<T>(adapter) {
getFilters
);

const selectItemSelected: MemoizedSelector<V, T> = createSelector(selectState, getItemSelected) as MemoizedSelector<V, T>;
const selectEntitiesSelected: MemoizedSelector<V, Dictionary<T>> = createSelector(selectState, getEntitiesSelected) as MemoizedSelector<V, Dictionary<T>>
const selectItemsSelected: MemoizedSelector<V, T[]> = createSelector(selectEntitiesSelected, (entities: Dictionary<T>) => Object.values(entities)) as MemoizedSelector<V, T[]>

Expand All @@ -76,7 +80,8 @@ export function createCrudSelectorsFactory<T>(adapter) {
selectIsLoading,
selectIsLoaded,
selectLastCriteria,
selectResponses
selectResponses,
selectItemSelected
} = getCrudBaseSelectors(selectState);

const {
Expand Down

0 comments on commit 651a7df

Please sign in to comment.