我正在尝试通过属性过滤掉有效负载数据。
//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;
下面是选择器
// Selector.ts
export const selectHomeQueues = createSelector(
fromReducer.selectAllMessages,
(messages) => messages.filter(message => message.queue === 'HOME')
);
我在减速器中接收数据,但在运行时选择器中出现错误ERROR TypeError: Cannot read property 'map' of undefined
注意:我无法在任何地方找到任何关于在 NGRX 实体选择器中进行过滤的示例。
我们如何过滤 NGRX 实体中的选择器?