Skip to content

Instantly share code, notes, and snippets.

@chapel

chapel/actions.js

Created Feb 21, 2016
Embed
What would you like to do?
import { combineReducers } from 'redux'
import { createAction, reduceActions } from './playground';
export const addTodo = createAction('ADD_TODO', combineReducers({
todos(state = [], text) {
return [
{
id: state.reduce((maxId, todo) => Math.max(todo.id, maxId), -1) + 1,
completed: false,
text
},
...state
];
},
history(state = {}, text) {
return {
...state,
lastEnteredText: text
};
}
}));
export const reducer = reduceActions([
addTodo
], {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.