Closed beiluo closed 8 years ago
//actions.js var _ = {sync: true, children: ['completed', 'failed']}; module.exports = Reflux.createActions({ getNews: _, addNews:_ });
//createStore.js var actions = require("./actions"); module.exports = Reflux.createStore({ listenables: actions, init: function () { }, OnGetNews: function () { console.log('OnGetNews') this.trigger({}); } });
//listStore.js var actions = require("./actions"); Reflux.createStore({ listenables: actions, init: function () { }, OnGetNews: function () { console.log('OnGetNews') this.trigger({}); }, OnAddNews: function () { console.log('OnAddNews') this.trigger({}); } });
//components create.jsx import actions from './actions' import store from './createStore' module.exports = React.createClass({ mixins: [ ListenerMixin, Reflux.connect(store), ], componentDidMount() { actions.getNews(); }, render(){ //body } })
//components list.jsx import actions from './actions' import store from './listStore' module.exports = React.createClass({ mixins: [ ListenerMixin, Reflux.connect(store), ], componentDidMount() { //actions.getNews(); }, render(){ //body } })
The first loading list.jsx Then load create.jsx Result:
OnGetNews OnGetNews
I want results:
OnGetNews
How to cancel listStore listen?
You should be able to listStore.stopListeningTo(actions.getNews) when you want the store to stop listening to that action.
listStore.stopListeningTo(actions.getNews)
thank you
The first loading list.jsx Then load create.jsx Result:
I want results:
How to cancel listStore listen?