Skip to content

Instantly share code, notes, and snippets.

@whyu
whyu / dispatcher.js
Created June 23, 2017 14:41
Wrap flux dispatcher
function wrapFlux(MainApp, availableActions, defaultStore) {
return React.createClass({
getInitialState: function() {
return $.extend({}, defaultStore, this.props.additionalData);
},
dispatcher: function(action, extras) {
// if an array of actions is passed in
if (Array.isArray(action)) {
var promiseArr = []; // Create Promise Array