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 11var React = require ( 'react' ) ;
2- var Api = require ( '../utils/api ' ) ;
2+ var TopicStore = require ( '../stores/topic-store ' ) ;
33
44module . exports = React . createClass ( {
55 getInitialState : function ( ) {
@@ -8,11 +8,13 @@ module.exports = React.createClass({
88 }
99 } ,
1010 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
1315 this . setState ( {
14- topics : data . data
15- } )
16+ topics : TopicStore . topics
17+ } ) ;
1618 } . bind ( this ) ) ;
1719 } ,
1820 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