I am trying to filter out the payload data by a property.
//reducer.ts
case MessagesActionTypes.LOAD_Message_SUCCESS: {
console.log('reducer='+
JSON.stringify(action.payload.Messages));//receiving data here
return adapter.addAll(action.payload.Messages, state);
}
export const getSelectedMessageId = (state: MessageState) => state.selectedMessageId;
// get the selectors
const { selectIds, selectEntities, selectAll, selectTotal } = adapter.getSelectors();
// select the array of Messages
export const selectAllMessages = selectAll;
Below is the selector
// Selector.ts
export const selectHomeQueues = createSelector(
fromReducer.selectAllMessages,
(messages) => messages.filter(message => message.queue === 'HOME')
);
I am receiving data in the reducer but getting error in the selector during runtime ERROR TypeError: Cannot read property 'map' of undefined
Note: I havent been able to find any example on filtering in NGRX entity selectors anywhere.
How do we filter the selectors in NGRX entity?