Created
May 28, 2018 19:36
-
-
Save kyuwoo-choi/bfb5ac43847e0adcfa95b28397045814 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 createStore from 'redux-zero'; | |
const initialState = { route: '', todoList: [] }; | |
const store = createStore(initialState); | |
export default store; | |
import store from './store'; | |
function actionCreator(action) { | |
return function() { | |
let state = store.getState(); | |
state = action(state, ...arguments); | |
store.setState(state); | |
}; | |
} | |
... | |
export const remove = actionCreator((state, id) => { | |
state.todoList = state.todoList.filter(todo => todo.id !== id); | |
return state; | |
}); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment