redux-retype-actions
Version:
Change the type of your actions
26 lines (24 loc) • 636 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var enableRetyping = exports.enableRetyping = function enableRetyping(reducer) {
return function retypedReducer(state, action) {
if (action.retype) {
return retypedReducer(retypedReducer(state, {
type: action.type,
payload: action.payload,
action: action.action
}), action.action);
}
return reducer(state, action);
};
};
var retypeAction = exports.retypeAction = function retypeAction(type, action, payload) {
return {
type: type,
action: action,
payload: payload,
retype: true
};
};