- implementing immutable.js

This commit is contained in:
2019-07-17 03:21:23 -04:00
parent 8ecf036cc4
commit 434a1ded24
39 changed files with 1123 additions and 187 deletions

View File

@@ -1,16 +1,17 @@
import { Map } from 'immutable';
import { EVENTS_LOADED, GET_EVENTS } from '../constants/actionTypes.js';
export const events = (state = {}, action) => {
export const events = (state = new Map(), action) => {
switch (action.type) {
case GET_EVENTS:
return Object.assign({}, state, {
isFetching: true,
});
case EVENTS_LOADED:
return Object.assign({}, state, {
events: action.payload,
isFetching: false,
});
return state.merge(
action.payload.toMap().mapEntries((entry) => {
const [, event] = entry;
return [`${event.id}`, event];
}),
);
case GET_EVENTS:
default:
return state;
}