react-chrome-redux
Version:
A set of utilities for building Redux applications in Google Chrome Extensions.
26 lines (22 loc) • 638 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Simple middleware intercepts actions and replaces with
* another by calling an alias function with the original action
* @type {object} aliases an object that maps action types (keys) to alias functions (values) (e.g. { SOME_ACTION: newActionAliasFunc })
*/
exports.default = function (aliases) {
return function () {
return function (next) {
return function (action) {
var alias = aliases[action.type];
if (alias) {
return next(alias(action));
}
return next(action);
};
};
};
};