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