Reflux uses Actions to tell the Stores when to update. We will wire Actions and Stores together to create a simple updatable age field React component.
In general, stores can be used in many components. And the component can subscribe to many stores. It means, stores should know NOTHING about subscribed components states. So I would rather write something like:
var store = Reflux.createStore({
listenables: [actions],
onUpdateAge() {
person.age = Math.random() * 100;
this.trigger({person});
}
});
var App = React.createClass({
mixins: [Reflux.connect(store, 'updatePerson')],
updatePerson(person) {
this.setState({person})
}
//...
})