package.cjs.react-utils.withImmutableActions.withImmutableActions.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neeto-commons-frontend Show documentation
Show all versions of neeto-commons-frontend Show documentation
A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _ramda = require("ramda");
var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
return function (partial) {
return set(function (previous) {
if (typeof partial === "function") partial = partial(previous);
var overwrittenActions = (0, _ramda.keys)(partial).filter(function (key) {
return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
});
if (!(0, _ramda.isEmpty)(overwrittenActions)) {
throw new Error("Actions should not be modified. Touched action(s): ".concat(overwrittenActions.join(", ")));
}
return partial;
}, false);
};
};
var withImmutableActions = function withImmutableActions(config) {
return function (set, get, api) {
return config(setWithoutModifyingActions(set), get, api);
};
};
var _default = withImmutableActions;
exports["default"] = _default;
//# sourceMappingURL=withImmutableActions.js.map