File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1
1
var React = require ( 'react' ) ;
2
- var Api = require ( '../utils/api ' ) ;
2
+ var TopicStore = require ( '../stores/topic-store ' ) ;
3
3
4
4
module . exports = React . createClass ( {
5
5
getInitialState : function ( ) {
@@ -8,11 +8,13 @@ module.exports = React.createClass({
8
8
}
9
9
} ,
10
10
componentWillMount : function ( ) {
11
- Api . get ( 'topics/defaults' )
12
- . then ( function ( data ) {
11
+ TopicStore . getTopics ( )
12
+ . then ( function ( ) {
13
+ // We have successfully fetched topics
14
+ // topics are available on TopicStore.topics
13
15
this . setState ( {
14
- topics : data . data
15
- } )
16
+ topics : TopicStore . topics
17
+ } ) ;
16
18
} . bind ( this ) ) ;
17
19
} ,
18
20
render : function ( ) {
Original file line number Diff line number Diff line change
1
+ var Api = require ( '../utils/api' ) ;
2
+ var Reflux = require ( 'reflux' ) ;
3
+
4
+ module . exports = Reflux . createStore ( {
5
+ getTopics : function ( ) {
6
+ return Api . get ( 'topics/defaults' )
7
+ . then ( function ( json ) {
8
+ this . topics = json . data ;
9
+ } . bind ( this ) ) ;
10
+ }
11
+ } ) ;
You can’t perform that action at this time.
0 commit comments