Dispatchr
A Flux dispatcher for applications that run on the server and the client.
Usage
For a more detailed example, see our example application.
Let's start with a store that can handle the actions:
var util = require('util'),
EventEmitter = require('events').EventEmitter;
function ExampleStore(context) {
this.navigating = false;
}
util.inherits(ExampleStore, EventEmitter);
ExampleStore.handlers = {
'NAVIGATE': 'handleNavigate'
};
ExampleStore.prototype.handleNavigate = function () {
this.navigating = true;
this.emit('update');
this.emit('final');
};
ExampleStore.prototype.getState = function () {
return {
navigating: this.navigating
};
};
Now let's initialize our dispatcher and dispatch an action:
var Dispatchr = require('dispatchr'),
ExampleStore = require('./example-store.js'),
context = {};
Dispatchr.registerStore(ExampleStore);
var dispatcher = new Dispatchr(context);
dispatcher.dispatch('NAVIGATE', {}, function () {
});
License
This software is free to use under the Yahoo! Inc. BSD license.
See the LICENSE file for license text and copyright information.