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

package.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
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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy