import { List, fromJS } from "immutable"; const defaultState = List(); const handlers = { ADD_NOTIFICATION: (state, action) => state.push( fromJS({ id: Math.random() .toString(36) .substring(7), ...action.payload }) ), REMOVE_NOTIFICATION: (state, action) => state.filter(e => e.get("id") !== action.payload.id) }; export default (state = defaultState, action) => handlers[action.type] ? handlers[action.type](state, action) : state;