Last active
August 29, 2015 14:24
-
-
Save christianalfoni/2cce0e5f05df74cca8af to your computer and use it in GitHub Desktop.
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
import Store from 'immutable-store'; | |
// Any mutations to an immutable-store returns the new mutated store as a result of the operation. | |
// More info at: https://github.com/christianalfoni/immutable-store | |
export default function (state = Store({todos: []}), action) { | |
switch (action.type) { | |
case ADD_TODO: | |
return state.todos.push(action.payload); | |
case REMOVE_TODO: | |
return state.todos.splice(action.payload, 1); | |
default: | |
return state; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In case you want to leverage existing persistent data structure, you can replace whole
immutable-store
with https://facebook.github.io/immutable-js/docs/#/Map/updateIn method.