Skip to content

Instantly share code, notes, and snippets.

@michaelerobertsjr
Created November 16, 2015 23:23
Show Gist options
  • Save michaelerobertsjr/ce0ae291ac986cc8fa80 to your computer and use it in GitHub Desktop.
Save michaelerobertsjr/ce0ae291ac986cc8fa80 to your computer and use it in GitHub Desktop.
Simple Flux Dispatcher
var guid = require('guid');
var listeners = {};
module.exports = {
register: function(cb) {
var id = guid.raw();
listeners[id] = callback;
return id;
},
dispatch: function(payload) {
console.info('Dispatching...', payload);
for (var id in listeners) {
var listener = listeners[id];
listener(payload);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment