adding step 2.4 and 2.5 exercises

This commit is contained in:
Ken
2019-03-02 22:56:59 -08:00
parent f459ad5823
commit 8446b010c9
13 changed files with 440 additions and 15 deletions

View File

@@ -5,11 +5,7 @@ import { composeWithDevTools } from 'redux-devtools-extension';
const store = createStore(reducer, {}, composeWithDevTools());
store.dispatch(actions.addTodo('hello'));
let action = actions.addTodo('world');
store.dispatch(action);
store.dispatch(actions.remove(action.id));
// TODO: try doing some store.dispatch() calls here
// HINT: remember to use the functions inside "actions" object
console.log(store.getState());

View File

@@ -6,7 +6,7 @@ export const todosReducer = createReducer<Store['todos']>(
{},
{
addTodo(state, action) {
state[action.id] = { label: action.label, completed: false };
// TODO: implement this reducer
},
remove(state, action) {
@@ -14,10 +14,6 @@ export const todosReducer = createReducer<Store['todos']>(
},
clear(state, action) {
state[action.id].completed = !state[action.id].completed;
},
complete(state, action) {
Object.keys(state).forEach(key => {
if (state[key].completed) {
delete state[key];
@@ -25,8 +21,12 @@ export const todosReducer = createReducer<Store['todos']>(
});
},
complete(state, action) {
// TODO: implement this reducer
},
edit(state, action) {
state[action.id].label = action.label;
// TODO: implement this reducer
}
}
);