My goal is to create a selector based on a parametrized selector. I believe this approach will only emit when a specific item is updated, which aligns with my requirements.
const getFeatureState = createFeatureSelector<FragmentsHierarchyState>(MY_FEATURE);
const getItem = createSelector(
getFeatureState,
(state: FeatureState, props: { itemId: string }) => {
return state.items[props.itemId];
}
);
const getItemValue = createSelector(
getItem, // <<< How can I pass props here?
(state: ItemState) => return state.x + state + y
);
I prefer not to do the following because I don't want new values to be emitted every time the feature state is updated:
const getItemValue = createSelector(
getFeatureState,
(state: FeatureState, props: { itemId: string }) => {
return state.items[props.itemId].x + state.items[props.itemId].y;
}
);