Skip to content

Commit bfb7862

Browse files
use AppDispatcher
1 parent aa455a7 commit bfb7862

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ep27-use-dispatcher/app/actions/TodoActions.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var api = require("../utils/api");
22
var TodoStore = require("../stores/TodoStore");
3+
var AppDispatcher = require('../dispatcher/AppDispatcher');
34

45
var TodoActions = {
56

@@ -26,7 +27,12 @@ var TodoActions = {
2627
api.markTodoDone(todo)
2728
.then( () => {
2829
console.log("marked TODO as done successfully");
29-
TodoStore.markTodoDone(todo);
30+
//TodoStore.markTodoDone(todo);
31+
AppDispatcher.dispatch({
32+
actionType: 'TODO_DONE',
33+
todo: todo
34+
});
35+
3036
})
3137
},
3238

ep27-use-dispatcher/app/stores/TodoStore.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
var AppDispatcher = require('../dispatcher/AppDispatcher');
2+
3+
AppDispatcher.register(function(action) {
4+
5+
switch(action.actionType) {
6+
case 'TODO_DONE':
7+
console.log("Handling TODO_DONE using dispatcher in store");
8+
break;
9+
}
10+
11+
});
12+
113
var _todos = {};
214
var _callback;
315

0 commit comments

Comments
 (0)