In Flux, Stores are the implementation of the data functions enumerated in the Action interfaces.
For each action defined in the related Action, you should define a handler. For an action called load
, the handler should be called onLoad
. For each of the child actions of load
, such as completed
and failed
, the handlers should be called onLoadCompleted
and onLoadFailed
.
This is magic that Reflux does for you.
EventTypeStore.js
import Reflux from 'reflux';
import Actions from '../actions/EventTypeActions';
module.exports = Reflux.createStore({
listenables: Actions,
init () {
this.eventTypes = [];
},
onLoad (personId) {
this.changed();
// load the person, call the callback
},
onLoadPersonCompleted (person) {
this.person = person;
this.changed();
}
});