Skip to content

Commit e825623

Browse files
split method into two thens
1 parent 60b2c94 commit e825623

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

ep29-emit/app/actions/TodoActions.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ var TodoActions = {
77
addTodo: (todo) => {
88
console.log("adding TODO");
99
api.addTodo(todo)
10+
.then( () => {
11+
api.getTodos()
12+
.then( (responseData) => {
13+
var todos = responseData.todos;
14+
console.log("All todos", todos);
15+
TodoStore.setTodos(todos);
16+
})
17+
})
1018
.then( () => {
1119
console.log("Added TODO successfully");
12-
TodoActions.getAllTodosAndUpdateStore();
20+
AppDispatcher.dispatch({
21+
actionType: 'TODO_ADD'
22+
});
1323
})
1424
},
1525

@@ -50,18 +60,8 @@ var TodoActions = {
5060
})
5161
},
5262

53-
getAllTodosAndUpdateStore: () => {
54-
console.log("Performing getAllTodos");
55-
api.getTodos()
56-
.then( (responseData) => {
57-
var todos = responseData.todos;
58-
console.log("new todos", todos);
59-
TodoStore.setTodos(todos);
60-
AppDispatcher.dispatch({
61-
actionType: 'TODO_ADD'
62-
});
63-
})
64-
}
63+
64+
6565

6666
}
6767

0 commit comments

Comments
 (0)