Step 8: combine reducers

This commit is contained in:
Ken
2019-02-17 18:12:26 -08:00
parent eb620843b9
commit 279a43fb35
16 changed files with 394 additions and 14 deletions

View File

@@ -1,19 +1,16 @@
import { Store } from '../store';
import { addTodo, remove, complete } from './pureFunctions';
import { clear } from '../../../step2-07/src/reducers/pureFunctions';
let index = 0;
export function reducer(state: Store, payload: any): Store {
switch (payload.type) {
export function reducer(state: Store, action: any): Store {
switch (action.type) {
case 'addTodo':
return addTodo(state, payload.label);
return addTodo(state, action.label);
case 'remove':
return remove(state, payload.id);
return remove(state, action.id);
case 'complete':
return complete(state, payload.id);
return complete(state, action.id);
}
return state;