Skip to content

Instantly share code, notes, and snippets.

@kyuwoo-choi
Created May 28, 2018 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyuwoo-choi/bfb5ac43847e0adcfa95b28397045814 to your computer and use it in GitHub Desktop.
Save kyuwoo-choi/bfb5ac43847e0adcfa95b28397045814 to your computer and use it in GitHub Desktop.
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