Created
February 21, 2016 06:02
-
-
Save chapel/0e9f81007a5db2037ac6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 { 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