Skip to content

Instantly share code, notes, and snippets.

@jhta
Created June 19, 2015 19:03
Show Gist options
  • Save jhta/13b9e0f93229fb62faf5 to your computer and use it in GitHub Desktop.
Save jhta/13b9e0f93229fb62faf5 to your computer and use it in GitHub Desktop.
dispatcher
var Dispatcher = require('flux').Dispatcher;
var assign = require('object-assign');
var n = 0;
var Dispatcher = assign( new Dispatcher(), {
handleViewAction( action ) {
n++;
// console.log(`dispatch #${n}`,action.type);
var payload = {
source : 'VIEW_ACTION',
action : action
};
// console.log(payload);
this.dispatch(payload);
},
handleServerAction( action ) {
n++;
// console.log(`dispatch server #${n}`,action.type);
var payload = {
source: 'SERVER_ACTION',
action: action
}
this.dispatch(payload);
}
});
module.exports = Dispatcher;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment