Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/componentMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ module.exports = {
throw new Error('Components may only bind to before, failed and after events');
}

self._actionMapper[ key ] = cb;
if(!Array.isArray(self._actionMapper[ key ])) {
self._actionMapper[ key ] = [];
}

self._actionMapper[ key ].push(cb);
});
},

Expand Down Expand Up @@ -181,7 +185,9 @@ module.exports = {
*/
onDispatch : function onDispatch(payload) {
if (this.isMounted() && this._actionMapper[ payload.actionType ]) {
this._actionMapper[ payload.actionType ](payload.actionType, payload.payload);
_.forEach(this._actionMapper[ payload.actionType ], function(action) {
action.call(this, payload.actionType, payload.payload);
});
}
}
};
22 changes: 13 additions & 9 deletions lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,11 @@ BaseStore.prototype._initActions = function initActions(actions) {

value.forEach(function processAction(name) {
name = namespaceTransform(name);
if (!Array.isArray(self._actionTypes[name])) {
self._actionTypes[name] = [];
}

self._actionTypes[name] = method;
self._actionTypes[name].push(method);
});
});
};
Expand Down Expand Up @@ -120,15 +123,16 @@ BaseStore.prototype.getStore = function getStore(name) {
* @param {Object} payload
*/
BaseStore.prototype._processActionEvent = function _processActionEvent(payload) {
var method = this._actionTypes[ payload.actionType ];

if (method && this[ method ]) {
if (['replaceState', 'setState'].indexOf(method) === -1) {
this[ method ](payload.payload, payload.actionType);
} else {
this[ method ](payload.payload);
var methods = this._actionTypes[ payload.actionType ];
_.forEach(methods, function checkMethod(method) {
if (method && this[ method ]) {
if (['replaceState', 'setState'].indexOf(method) === -1) {
this[ method ](payload.payload, payload.actionType);
} else {
this[ method ](payload.payload);
}
}
}
}, this);

return this;
}; /*jshint ignore:line */
Expand Down