package.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.
import { isEmpty, keys } from "ramda";
var setWithoutModifyingActions = function setWithoutModifyingActions(set) {
return function (partial) {
return set(function (previous) {
if (typeof partial === "function") partial = partial(previous);
var overwrittenActions = keys(partial).filter(function (key) {
return typeof (previous === null || previous === void 0 ? void 0 : previous[key]) === "function" && partial[key] !== previous[key];
});
if (!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);
};
};
export default withImmutableActions;
//# sourceMappingURL=withImmutableActions.js.map