mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Step 8: combine reducers
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user