Skip to content

Instantly share code, notes, and snippets.

@IrakliJani
Last active July 30, 2016 18:18
Show Gist options
  • Save IrakliJani/c7b4d262838610e11cef3a69b00c86d3 to your computer and use it in GitHub Desktop.
Save IrakliJani/c7b4d262838610e11cef3a69b00c86d3 to your computer and use it in GitHub Desktop.
Reducer with immutable.js
function tasksReducer (state = Map(), action) {
switch (action.type) {
case ADD_TASK:
return state.set(action.task.id, action.task)
case REMOVE_TASK:
return state.delete(action.id)
case COMPLETE_TASK:
return state.updateIn([action.id, 'completed'], true)
default:
return state
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment