想象一下,你有一个巨大的动作对象,而某些组件/商店只想听它的子集。
var actions = Reflux.createActions({ /* lots of actions with children*/});
如何只收听subset
这些操作,而不是逐个手动this.listenTo()
?最简单的方法?
答案 0 :(得分:1)
所以你容易做到。
在店内:
// ...
var actions = Reflux.createActions({ /* lots of actions with children*/});
module.exports = Reflux.createStore({
listenables: {subsetKey: actions.subsetKey},
// ...
在组件中:
// ...
var actions = Reflux.createActions({ /* lots of actions with children*/});
module.exports = React.createClass({
mixins: [Reflux.ListenerMixin],
componentDidMount() {
this.listenToMany({subsetKey: actions.subsetKey});
}
// ...