NetanelBasal
8/28/2017 - 11:21 AM

select-store4.ts

const initStateNormalize = {
  entities: {
    1: {
      id: 1,
      text: 'Todo one'
    }
  },
  result: [1]
};
const todosNormalized = ( state = initStateNormalize, action ) => {
  switch( action.type ) {
    case 'ADD_TODO':
      return {
        entities: {
          ...state.entities,
          [action.payload.id]: action.payload
        },
        result: state.result.concat([action.payload.id])
      }
    default:
      return state;
  }
}