File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed
ep28-more-dispatcher-usage/app Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 1
1
var api = require ( "../utils/api" ) ;
2
2
var TodoStore = require ( "../stores/TodoStore" ) ;
3
3
var AppDispatcher = require ( '../dispatcher/AppDispatcher' ) ;
4
+ var Constants = require ( "../utils/constants" ) ;
4
5
5
6
var TodoActions = {
6
7
@@ -15,7 +16,7 @@ var TodoActions = {
15
16
api . deleteTodo ( todo . id )
16
17
. then ( ( ) => {
17
18
AppDispatcher . dispatch ( {
18
- actionType : ' TODO_DELETE' ,
19
+ actionType : Constants . TODO_DELETE ,
19
20
todo : todo
20
21
} ) ;
21
22
} )
@@ -25,7 +26,7 @@ var TodoActions = {
25
26
api . markTodoDone ( todo )
26
27
. then ( ( ) => {
27
28
AppDispatcher . dispatch ( {
28
- actionType : ' TODO_DONE' ,
29
+ actionType : Constants . TODO_DONE ,
29
30
todo : todo
30
31
} ) ;
31
32
@@ -36,7 +37,7 @@ var TodoActions = {
36
37
api . markTodoUnDone ( todo )
37
38
. then ( ( ) => {
38
39
AppDispatcher . dispatch ( {
39
- actionType : ' TODO_UNDONE' ,
40
+ actionType : Constants . TODO_UNDONE ,
40
41
todo : todo
41
42
} ) ;
42
43
} )
@@ -48,7 +49,7 @@ var TodoActions = {
48
49
var todos = responseData . todos ;
49
50
TodoStore . setTodos ( todos ) ;
50
51
AppDispatcher . dispatch ( {
51
- actionType : ' TODO_ADD'
52
+ actionType : Constants . TODO_ADD
52
53
} ) ;
53
54
} )
54
55
}
Original file line number Diff line number Diff line change 1
1
var AppDispatcher = require ( '../dispatcher/AppDispatcher' ) ;
2
+ var Constants = require ( "../utils/constants" ) ;
2
3
3
4
AppDispatcher . register ( function ( action ) {
4
5
5
6
switch ( action . actionType ) {
6
- case ' TODO_DONE' :
7
+ case Constants . TODO_DONE :
7
8
TodoStore . markTodoDone ( action . todo ) ;
8
9
break ;
9
10
10
- case ' TODO_UNDONE' :
11
+ case Constants . TODO_UNDONE :
11
12
TodoStore . markTodoUnDone ( action . todo ) ;
12
13
break ;
13
14
14
- case ' TODO_DELETE' :
15
+ case Constants . TODO_DELETE :
15
16
TodoStore . deleteTodo ( action . todo ) ;
16
17
break ;
17
18
18
- case ' TODO_ADD' :
19
+ case Constants . TODO_ADD :
19
20
TodoStore . getTodos ( ) ;
20
21
break ;
21
22
}
Original file line number Diff line number Diff line change 1
1
var Constants = {
2
2
BASE_URL : "http://lrjis-api-production.herokuapp.com/api/v1/" ,
3
- API_KEY : "4d5e466a-97a4-46ba-bb3d-3da6c4347965"
3
+ API_KEY : "4d5e466a-97a4-46ba-bb3d-3da6c4347965" ,
4
+ TODO_DONE : 'TODO_DONE' ,
5
+ TODO_UNDONE : 'TODO_UNDONE' ,
6
+ TODO_DELETE : 'TODO_DELETE' ,
7
+ TODO_ADD : 'TODO_ADD'
4
8
} ;
5
9
module . exports = Constants ;
You can’t perform that action at this time.
0 commit comments