All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.react-utils.withImmutableActions.withImmutableActions.js Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
"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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy