I read this article https://blog.angularindepth.com/ngrx-parameterized-selector-e3f610529f8
And not found how to adapt to pass a params into my selectors
I tried pass a props object into my component to the selector.
[EDITED] answer with @Julius Dzidzevičius solution.
in component
this.store.pipe(select(fromRoot.selectors.getPreferences, 'myProps'))
in AppState
const rootSelectors = {
layout: (state: AppState) => _.get(state, 'layout'),
}
export interface Selectors {
getPreferences: MemoizedSelectorWithProps<AppState, string, Preference[]>;
}
export const selectors: Selectors = {
getPreferences: createSelector(
rootSelectors.layout,
(state: LayoutState, props: string)
=> layoutSelectors.preferences(state, props))
};
in state
export const layoutSelectors = {
preferences: (state: LayoutState, props: string) => {
return state.filter(item => item.name === props)
},
};
If someone could tell me just how to adapt correctly this parameter. from component to selector through the memoized Selector.