@ngxs/store 3.8.1-dev.master-c0944d0 → 3.8.1-dev.master-94c82c4
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
|
/**
|