I am currently working on an ngrx store project using ngrx entites in which I would like to compose some selectors, like this:
export const selectProductById = (productId: number) => createSelector(
selectProductState,
productsState => productsState.entities[productId]
);
export const selectCurrentProduct = createSelector(
selectProductState,
productsState => productsState.entities[productsState.selectedProductId]
);
I would like to use the selectProductById
selector in the selectCurrentProduct
selector, like this:
// doesn't work
export const selectCurrentProduct = createSelector(
selectProductState,
productsState => selectProductById(productsState.selectedProductId)
);
What would be the syntax? This causes compilation errors where I try to use the selectCurrentProduct
selector:
Type 'Observable<emoizedSelector<object, Product>>' is not assignable to type 'Observable<Product>'
Update
Thanks for all the links and stuff, but they don't really address my problem. I am looking to create a selector using createSelector()
using another selector, also created by createSelector()
. Please see my pseudocode above. I am trying to use te selectProductById
using the selectProductById
selector.