redux-dry-ts-actions
Version:
Micro library to create actions for redux with automatically inferred TypeScript types
23 lines (22 loc) • 710 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function createAction(type, payloadCreator) {
if (payloadCreator == null) {
var action_1 = { type: type };
return Object.assign(function () { return action_1; }, { actionType: type });
}
else {
var f = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return ({
payload: payloadCreator.apply(void 0, args),
type: type,
});
};
return Object.assign(f, { actionType: type });
}
}
exports.createAction = createAction;