Last active
July 30, 2016 18:18
-
-
Save IrakliJani/c7b4d262838610e11cef3a69b00c86d3 to your computer and use it in GitHub Desktop.
Reducer with immutable.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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