Skip to content

Commit c86c76f

Browse files
deleting Todo in store
1 parent 9428deb commit c86c76f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

ep26-enhance-todo-store/app/actions/TodoActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var TodoActions = {
1717
api.deleteTodo(todo.id)
1818
.then( () => {
1919
console.log("Deleted TODO successfully");
20-
TodoActions.getAllTodos();
20+
TodoStore.deleteTodo(todo);
2121
})
2222
},
2323

ep26-enhance-todo-store/app/stores/TodoStore.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ var _callback;
33

44
var TodoStore = {
55

6+
deleteTodo: (todo) => {
7+
var newTodos = _todos.filter( (t) => {
8+
return t.id != todo.id
9+
} )
10+
_todos = newTodos;
11+
_callback(_todos);
12+
},
13+
614
markTodoDone: (todo) => {
715
var _todo = _todos.filter((t) => {
816
return t.id === todo.id;

0 commit comments

Comments
 (0)