redux-duck
Version:
Helper function to create Redux modules using the ducks-modular-redux proposal.
3 lines (2 loc) • 839 B
JavaScript
;var e={type:"@@INVALID"};exports.createDuck=function(r,n){return{defineType:function(e){return n?n+"/"+r+"/"+e:r+"/"+e},createReducer:function(r,n){return function(e){if(0===e.length)throw new Error("You should pass at least one case name when creating a reducer.");var r=e.filter((function(e){return"undefined"!==e}));if(0===r.length)throw new Error("All of your action types are undefined.");if(r.length!==Object.keys(e).length)throw new Error("One or more of your action types are undefined. Valid cases are: "+r.join(", ")+".")}(Object.keys(r)),function(t,o){for(var i in void 0===t&&(t=n),void 0===o&&(o=e),r)if(o.type===i)return r[i](t,o);return t}},createAction:function(e,r){return void 0===r&&(r=!1),function(n,t){return{type:e,payload:n,error:r,meta:t}}}}};
//# sourceMappingURL=redux-duck.cjs.production.min.js.map