React dispatcher
npm install flux-react-dispatcher
Part of flux-react, the dispatcher will let stores register to it with
callbacks. Read more about FLUX and the dispatcher over at Facebook Flux.
Download from dist: ReactDispatcher.min.js or install with npm install flux-react-dispatcher.
javascript
var ReactDispatcher = require('flux-react-dispatcher');
var Dispatcher = new ReactDispatcher();var StoreA = {
dispatch: function () {}
};
var StoreB = {
data: {},
handleData: function (payload) {
this.data = payload.data;
},
dispatch: function (payload, waitFor) {
switch (payload.type) {
case 'update':
waitFor(StoreA, this.handleData);
break;
}
}
};
Dispatcher.register(StoreA, StoreA.dispatch); // Binds the callback to the store
Dispatcher.register(StoreB, StoreB.dispatch);
Dispatcher.dispatch({});
`Contribute
$3
* Run npm install
* Run gulp
* Any changes to files in app/ will be compiled to dev/$3
* Run gulp test -'./tests/ReactDispatcher-test.js'test.html file in your browserapp/ and the test file will autoreload the browsernpm test