Skip to content

Instantly share code, notes, and snippets.

@tribou
Created October 15, 2015 01:07
Show Gist options
  • Save tribou/8716639aa77f232c4a2e to your computer and use it in GitHub Desktop.
Save tribou/8716639aa77f232c4a2e to your computer and use it in GitHub Desktop.
A sample Flux dispatcher implemented in an ES6 class
// Todo app dispatcher with actions responding to both
// view and server actions
import { Dispatcher } from 'flux';
class DispatcherClass extends Dispatcher {
handleViewAction(action) {
this.dispatch({
source: 'VIEW_ACTION',
action: action,
});
}
handleServerAction(action) {
this.dispatch({
source: 'SERVER_ACTION',
action: action,
});
}
}
const AppDispatcher = new DispatcherClass();
export default AppDispatcher;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment