@ngxs/store 3.8.1-dev.master-c0944d0 → 3.8.1-dev.master-84a340f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store/internals'), require('@angular/common'), require('rxjs'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@ngxs/store', ['exports', '@angular/core', '@ngxs/store/internals', '@angular/common', 'rxjs', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs.store = {}), global.ng.core, global.ngxs.store.internals, global.ng.common, global.rxjs, global.rxjs.operators));
5
- })(this, (function (exports, i0, i5, common, rxjs, operators) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@ngxs/store/internals'), require('@angular/common'), require('rxjs'), require('rxjs/operators'), require('@ngxs/store/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@ngxs/store', ['exports', '@angular/core', '@ngxs/store/internals', '@angular/common', 'rxjs', 'rxjs/operators', '@ngxs/store/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.ngxs = global.ngxs || {}, global.ngxs.store = {}), global.ng.core, global.ngxs.store.internals, global.ng.common, global.rxjs, global.rxjs.operators, global.ngxs.store.operators));
5
+ })(this, (function (exports, i0, i5, common, rxjs, operators, operators$1) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -1723,43 +1723,21 @@
1723
1723
  */
1724
1724
  StateContextFactory.prototype.createStateContext = function (mappedStore) {
1725
1725
  var root = this._internalStateOperations.getRootStateOperations();
1726
- function getState(currentAppState) {
1727
- return getValue(currentAppState, mappedStore.path);
1728
- }
1729
- function setStateValue(currentAppState, newValue) {
1730
- var newAppState = setValue(currentAppState, mappedStore.path, newValue);
1731
- root.setState(newAppState);
1732
- return newAppState;
1733
- // In doing this refactoring I noticed that there is a 'bug' where the
1734
- // application state is returned instead of this state slice.
1735
- // This has worked this way since the beginning see:
1736
- // https://github.com/ngxs/store/blame/324c667b4b7debd8eb979006c67ca0ae347d88cd/src/state-factory.ts
1737
- // This needs to be fixed, but is a 'breaking' change.
1738
- // I will do this fix in a subsequent PR and we can decide how to handle it.
1739
- }
1740
- function setStateFromOperator(currentAppState, stateOperator) {
1741
- var local = getState(currentAppState);
1742
- var newValue = stateOperator(local);
1743
- return setStateValue(currentAppState, newValue);
1744
- }
1745
- function isStateOperator(value) {
1746
- return typeof value === 'function';
1747
- }
1748
1726
  return {
1749
1727
  getState: function () {
1750
1728
  var currentAppState = root.getState();
1751
- return getState(currentAppState);
1729
+ return getState(currentAppState, mappedStore.path);
1752
1730
  },
1753
1731
  patchState: function (val) {
1754
1732
  var currentAppState = root.getState();
1755
1733
  var patchOperator = simplePatch(val);
1756
- return setStateFromOperator(currentAppState, patchOperator);
1734
+ return setStateFromOperator(root, currentAppState, patchOperator, mappedStore.path);
1757
1735
  },
1758
1736
  setState: function (val) {
1759
1737
  var currentAppState = root.getState();
1760
- return isStateOperator(val)
1761
- ? setStateFromOperator(currentAppState, val)
1762
- : setStateValue(currentAppState, val);
1738
+ return operators$1.isStateOperator(val)
1739
+ ? setStateFromOperator(root, currentAppState, val, mappedStore.path)
1740
+ : setStateValue(root, currentAppState, val, mappedStore.path);
1763
1741
  },
1764
1742
  dispatch: function (actions) {
1765
1743
  return root.dispatch(actions);
@@ -1774,6 +1752,25 @@
1774
1752
  type: i0.Injectable,
1775
1753
  args: [{ providedIn: 'root' }]
1776
1754
  }], ctorParameters: function () { return [{ type: InternalStateOperations }]; } });
1755
+ function setStateValue(root, currentAppState, newValue, path) {
1756
+ var newAppState = setValue(currentAppState, path, newValue);
1757
+ root.setState(newAppState);
1758
+ return newAppState;
1759
+ // In doing this refactoring I noticed that there is a 'bug' where the
1760
+ // application state is returned instead of this state slice.
1761
+ // This has worked this way since the beginning see:
1762
+ // https://github.com/ngxs/store/blame/324c667b4b7debd8eb979006c67ca0ae347d88cd/src/state-factory.ts
1763
+ // This needs to be fixed, but is a 'breaking' change.
1764
+ // I will do this fix in a subsequent PR and we can decide how to handle it.
1765
+ }
1766
+ function setStateFromOperator(root, currentAppState, stateOperator, path) {
1767
+ var local = getState(currentAppState, path);
1768
+ var newValue = stateOperator(local);
1769
+ return setStateValue(root, currentAppState, newValue, path);
1770
+ }
1771
+ function getState(currentAppState, path) {
1772
+ return getValue(currentAppState, path);
1773
+ }
1777
1774
 
1778
1775
  var NG_DEV_MODE = typeof ngDevMode === 'undefined' || ngDevMode;
1779
1776
  /**
@@ -2838,12 +2835,14 @@
2838
2835
  function createModelSelector(selectorMap) {
2839
2836
  var selectorKeys = Object.keys(selectorMap);
2840
2837
  var selectors = Object.values(selectorMap);
2841
- ensureValidSelectorMap({
2842
- prefix: '[createModelSelector]',
2843
- selectorMap: selectorMap,
2844
- selectorKeys: selectorKeys,
2845
- selectors: selectors,
2846
- });
2838
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2839
+ ensureValidSelectorMap({
2840
+ prefix: '[createModelSelector]',
2841
+ selectorMap: selectorMap,
2842
+ selectorKeys: selectorKeys,
2843
+ selectors: selectors
2844
+ });
2845
+ }
2847
2846
  return createSelector(selectors, function () {
2848
2847
  var args = [];
2849
2848
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -2862,12 +2861,14 @@
2862
2861
  ensureValueProvided(selectorKeys.length, { prefix: prefix, noun: 'non-empty selector map' });
2863
2862
  selectors.forEach(function (selector, index) { return ensureValidSelector(selector, {
2864
2863
  prefix: prefix,
2865
- noun: "selector for the '" + selectorKeys[index] + "' property",
2864
+ noun: "selector for the '" + selectorKeys[index] + "' property"
2866
2865
  }); });
2867
2866
  }
2868
2867
 
2869
2868
  function createPickSelector(selector, keys) {
2870
- ensureValidSelector(selector, { prefix: '[createPickSelector]' });
2869
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2870
+ ensureValidSelector(selector, { prefix: '[createPickSelector]' });
2871
+ }
2871
2872
  var validKeys = keys.filter(Boolean);
2872
2873
  var selectors = validKeys.map(function (key) { return createSelector([selector], function (s) { return s[key]; }); });
2873
2874
  return createSelector(__spreadArray([], __read(selectors)), function () {
@@ -2883,10 +2884,12 @@
2883
2884
  }
2884
2885
 
2885
2886
  function createPropertySelectors(parentSelector) {
2886
- ensureValidSelector(parentSelector, {
2887
- prefix: '[createPropertySelectors]',
2888
- noun: 'parent selector',
2889
- });
2887
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
2888
+ ensureValidSelector(parentSelector, {
2889
+ prefix: '[createPropertySelectors]',
2890
+ noun: 'parent selector'
2891
+ });
2892
+ }
2890
2893
  var cache = {};
2891
2894
  return new Proxy({}, {
2892
2895
  get: function (_target, prop) {
@@ -2894,7 +2897,7 @@
2894
2897
  createSelector([parentSelector], function (s) { return s === null || s === void 0 ? void 0 : s[prop]; });
2895
2898
  cache[prop] = selector;
2896
2899
  return selector;
2897
- },
2900
+ }
2898
2901
  });
2899
2902
  }
2900
2903