@ngxs/store 3.7.5 → 3.7.6
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.
- package/bundles/ngxs-store.umd.js +605 -483
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.min.js +1 -1
- package/bundles/ngxs-store.umd.min.js.map +1 -1
- package/esm2015/ngxs-store.js +6 -5
- package/esm2015/src/actions-stream.js +16 -4
- package/esm2015/src/internal/dispatcher.js +14 -36
- package/esm2015/src/internal/error-handler.js +118 -0
- package/esm2015/src/internal/internals.js +2 -27
- package/esm2015/src/internal/lifecycle-state-manager.js +85 -38
- package/esm2015/src/internal/state-context-factory.js +1 -12
- package/esm2015/src/internal/state-factory.js +4 -4
- package/esm5/ngxs-store.js +6 -5
- package/esm5/src/actions-stream.js +22 -5
- package/esm5/src/internal/dispatcher.js +13 -37
- package/esm5/src/internal/error-handler.js +125 -0
- package/esm5/src/internal/internals.js +2 -27
- package/esm5/src/internal/lifecycle-state-manager.js +97 -50
- package/esm5/src/internal/state-context-factory.js +1 -12
- package/esm5/src/internal/state-factory.js +4 -4
- package/fesm2015/ngxs-store.js +453 -341
- package/fesm2015/ngxs-store.js.map +1 -1
- package/fesm5/ngxs-store.js +602 -481
- package/fesm5/ngxs-store.js.map +1 -1
- package/ngxs-store.d.ts +6 -5
- package/ngxs-store.metadata.json +1 -1
- package/package.json +2 -2
- package/src/actions-stream.d.ts +3 -1
- package/src/internal/dispatcher.d.ts +3 -4
- package/src/internal/error-handler.d.ts +23 -0
- package/src/internal/internals.d.ts +1 -6
- package/src/internal/lifecycle-state-manager.d.ts +16 -15
|
@@ -730,156 +730,6 @@
|
|
|
730
730
|
NgxsExecutionStrategy.prototype.leave = function (func) { };
|
|
731
731
|
}
|
|
732
732
|
|
|
733
|
-
/**
|
|
734
|
-
* @fileoverview added by tsickle
|
|
735
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
736
|
-
*/
|
|
737
|
-
/**
|
|
738
|
-
* Returns the type from an action instance/class.
|
|
739
|
-
* @ignore
|
|
740
|
-
* @param {?} action
|
|
741
|
-
* @return {?}
|
|
742
|
-
*/
|
|
743
|
-
function getActionTypeFromInstance(action) {
|
|
744
|
-
if (action.constructor && action.constructor.type) {
|
|
745
|
-
return action.constructor.type;
|
|
746
|
-
}
|
|
747
|
-
else {
|
|
748
|
-
return action.type;
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
/**
|
|
752
|
-
* Matches a action
|
|
753
|
-
* @ignore
|
|
754
|
-
* @param {?} action1
|
|
755
|
-
* @return {?}
|
|
756
|
-
*/
|
|
757
|
-
function actionMatcher(action1) {
|
|
758
|
-
/** @type {?} */
|
|
759
|
-
var type1 = getActionTypeFromInstance(action1);
|
|
760
|
-
return (/**
|
|
761
|
-
* @param {?} action2
|
|
762
|
-
* @return {?}
|
|
763
|
-
*/
|
|
764
|
-
function (action2) {
|
|
765
|
-
return type1 === getActionTypeFromInstance(action2);
|
|
766
|
-
});
|
|
767
|
-
}
|
|
768
|
-
/**
|
|
769
|
-
* Set a deeply nested value. Example:
|
|
770
|
-
*
|
|
771
|
-
* setValue({ foo: { bar: { eat: false } } },
|
|
772
|
-
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
773
|
-
*
|
|
774
|
-
* While it traverses it also creates new objects from top down.
|
|
775
|
-
*
|
|
776
|
-
* @ignore
|
|
777
|
-
* @type {?}
|
|
778
|
-
*/
|
|
779
|
-
var setValue = (/**
|
|
780
|
-
* @param {?} obj
|
|
781
|
-
* @param {?} prop
|
|
782
|
-
* @param {?} val
|
|
783
|
-
* @return {?}
|
|
784
|
-
*/
|
|
785
|
-
function (obj, prop, val) {
|
|
786
|
-
obj = __assign({}, obj);
|
|
787
|
-
/** @type {?} */
|
|
788
|
-
var split = prop.split('.');
|
|
789
|
-
/** @type {?} */
|
|
790
|
-
var lastIndex = split.length - 1;
|
|
791
|
-
split.reduce((/**
|
|
792
|
-
* @param {?} acc
|
|
793
|
-
* @param {?} part
|
|
794
|
-
* @param {?} index
|
|
795
|
-
* @return {?}
|
|
796
|
-
*/
|
|
797
|
-
function (acc, part, index) {
|
|
798
|
-
if (index === lastIndex) {
|
|
799
|
-
acc[part] = val;
|
|
800
|
-
}
|
|
801
|
-
else {
|
|
802
|
-
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : __assign({}, acc[part]);
|
|
803
|
-
}
|
|
804
|
-
return acc && acc[part];
|
|
805
|
-
}), obj);
|
|
806
|
-
return obj;
|
|
807
|
-
});
|
|
808
|
-
/**
|
|
809
|
-
* Get a deeply nested value. Example:
|
|
810
|
-
*
|
|
811
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
812
|
-
*
|
|
813
|
-
* @ignore
|
|
814
|
-
* @type {?}
|
|
815
|
-
*/
|
|
816
|
-
var getValue = (/**
|
|
817
|
-
* @param {?} obj
|
|
818
|
-
* @param {?} prop
|
|
819
|
-
* @return {?}
|
|
820
|
-
*/
|
|
821
|
-
function (obj, prop) {
|
|
822
|
-
return prop.split('.').reduce((/**
|
|
823
|
-
* @param {?} acc
|
|
824
|
-
* @param {?} part
|
|
825
|
-
* @return {?}
|
|
826
|
-
*/
|
|
827
|
-
function (acc, part) { return acc && acc[part]; }), obj);
|
|
828
|
-
});
|
|
829
|
-
/**
|
|
830
|
-
* Simple object check.
|
|
831
|
-
*
|
|
832
|
-
* isObject({a:1}) //=> true
|
|
833
|
-
* isObject(1) //=> false
|
|
834
|
-
*
|
|
835
|
-
* @ignore
|
|
836
|
-
* @type {?}
|
|
837
|
-
*/
|
|
838
|
-
var isObject = (/**
|
|
839
|
-
* @param {?} item
|
|
840
|
-
* @return {?}
|
|
841
|
-
*/
|
|
842
|
-
function (item) {
|
|
843
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
844
|
-
});
|
|
845
|
-
/**
|
|
846
|
-
* Deep merge two objects.
|
|
847
|
-
*
|
|
848
|
-
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
849
|
-
*
|
|
850
|
-
* \@param base base object onto which `sources` will be applied
|
|
851
|
-
* @type {?}
|
|
852
|
-
*/
|
|
853
|
-
var mergeDeep = (/**
|
|
854
|
-
* @param {?} base
|
|
855
|
-
* @param {...?} sources
|
|
856
|
-
* @return {?}
|
|
857
|
-
*/
|
|
858
|
-
function (base) {
|
|
859
|
-
var sources = [];
|
|
860
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
861
|
-
sources[_i - 1] = arguments[_i];
|
|
862
|
-
}
|
|
863
|
-
var _a, _b;
|
|
864
|
-
if (!sources.length)
|
|
865
|
-
return base;
|
|
866
|
-
/** @type {?} */
|
|
867
|
-
var source = sources.shift();
|
|
868
|
-
if (isObject(base) && isObject(source)) {
|
|
869
|
-
for (var key in source) {
|
|
870
|
-
if (isObject(source[key])) {
|
|
871
|
-
if (!base[key])
|
|
872
|
-
Object.assign(base, (_a = {}, _a[key] = {}, _a));
|
|
873
|
-
mergeDeep(base[key], source[key]);
|
|
874
|
-
}
|
|
875
|
-
else {
|
|
876
|
-
Object.assign(base, (_b = {}, _b[key] = source[key], _b));
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
880
|
-
return mergeDeep.apply(void 0, __spread([base], sources));
|
|
881
|
-
});
|
|
882
|
-
|
|
883
733
|
/**
|
|
884
734
|
* @fileoverview added by tsickle
|
|
885
735
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -1004,17 +854,6 @@
|
|
|
1004
854
|
/** @type {?} */
|
|
1005
855
|
StatesAndDefaults.prototype.states;
|
|
1006
856
|
}
|
|
1007
|
-
/**
|
|
1008
|
-
* @record
|
|
1009
|
-
* @template T
|
|
1010
|
-
*/
|
|
1011
|
-
function RootStateDiff() { }
|
|
1012
|
-
if (false) {
|
|
1013
|
-
/** @type {?} */
|
|
1014
|
-
RootStateDiff.prototype.currentAppState;
|
|
1015
|
-
/** @type {?} */
|
|
1016
|
-
RootStateDiff.prototype.newAppState;
|
|
1017
|
-
}
|
|
1018
857
|
/**
|
|
1019
858
|
* Ensures metadata is attached to the class and returns it.
|
|
1020
859
|
*
|
|
@@ -1356,22 +1195,159 @@
|
|
|
1356
1195
|
* @param {?} obj
|
|
1357
1196
|
* @return {?}
|
|
1358
1197
|
*/
|
|
1359
|
-
function isObject
|
|
1198
|
+
function isObject(obj) {
|
|
1360
1199
|
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
1361
1200
|
}
|
|
1201
|
+
|
|
1362
1202
|
/**
|
|
1363
|
-
* @
|
|
1364
|
-
* @
|
|
1365
|
-
|
|
1203
|
+
* @fileoverview added by tsickle
|
|
1204
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1205
|
+
*/
|
|
1206
|
+
/**
|
|
1207
|
+
* Returns the type from an action instance/class.
|
|
1208
|
+
* @ignore
|
|
1209
|
+
* @param {?} action
|
|
1366
1210
|
* @return {?}
|
|
1367
1211
|
*/
|
|
1368
|
-
function
|
|
1369
|
-
|
|
1370
|
-
|
|
1212
|
+
function getActionTypeFromInstance(action) {
|
|
1213
|
+
if (action.constructor && action.constructor.type) {
|
|
1214
|
+
return action.constructor.type;
|
|
1215
|
+
}
|
|
1216
|
+
else {
|
|
1217
|
+
return action.type;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
/**
|
|
1221
|
+
* Matches a action
|
|
1222
|
+
* @ignore
|
|
1223
|
+
* @param {?} action1
|
|
1224
|
+
* @return {?}
|
|
1225
|
+
*/
|
|
1226
|
+
function actionMatcher(action1) {
|
|
1371
1227
|
/** @type {?} */
|
|
1372
|
-
var
|
|
1373
|
-
return
|
|
1228
|
+
var type1 = getActionTypeFromInstance(action1);
|
|
1229
|
+
return (/**
|
|
1230
|
+
* @param {?} action2
|
|
1231
|
+
* @return {?}
|
|
1232
|
+
*/
|
|
1233
|
+
function (action2) {
|
|
1234
|
+
return type1 === getActionTypeFromInstance(action2);
|
|
1235
|
+
});
|
|
1374
1236
|
}
|
|
1237
|
+
/**
|
|
1238
|
+
* Set a deeply nested value. Example:
|
|
1239
|
+
*
|
|
1240
|
+
* setValue({ foo: { bar: { eat: false } } },
|
|
1241
|
+
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
1242
|
+
*
|
|
1243
|
+
* While it traverses it also creates new objects from top down.
|
|
1244
|
+
*
|
|
1245
|
+
* @ignore
|
|
1246
|
+
* @type {?}
|
|
1247
|
+
*/
|
|
1248
|
+
var setValue = (/**
|
|
1249
|
+
* @param {?} obj
|
|
1250
|
+
* @param {?} prop
|
|
1251
|
+
* @param {?} val
|
|
1252
|
+
* @return {?}
|
|
1253
|
+
*/
|
|
1254
|
+
function (obj, prop, val) {
|
|
1255
|
+
obj = __assign({}, obj);
|
|
1256
|
+
/** @type {?} */
|
|
1257
|
+
var split = prop.split('.');
|
|
1258
|
+
/** @type {?} */
|
|
1259
|
+
var lastIndex = split.length - 1;
|
|
1260
|
+
split.reduce((/**
|
|
1261
|
+
* @param {?} acc
|
|
1262
|
+
* @param {?} part
|
|
1263
|
+
* @param {?} index
|
|
1264
|
+
* @return {?}
|
|
1265
|
+
*/
|
|
1266
|
+
function (acc, part, index) {
|
|
1267
|
+
if (index === lastIndex) {
|
|
1268
|
+
acc[part] = val;
|
|
1269
|
+
}
|
|
1270
|
+
else {
|
|
1271
|
+
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : __assign({}, acc[part]);
|
|
1272
|
+
}
|
|
1273
|
+
return acc && acc[part];
|
|
1274
|
+
}), obj);
|
|
1275
|
+
return obj;
|
|
1276
|
+
});
|
|
1277
|
+
/**
|
|
1278
|
+
* Get a deeply nested value. Example:
|
|
1279
|
+
*
|
|
1280
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
1281
|
+
*
|
|
1282
|
+
* @ignore
|
|
1283
|
+
* @type {?}
|
|
1284
|
+
*/
|
|
1285
|
+
var getValue = (/**
|
|
1286
|
+
* @param {?} obj
|
|
1287
|
+
* @param {?} prop
|
|
1288
|
+
* @return {?}
|
|
1289
|
+
*/
|
|
1290
|
+
function (obj, prop) {
|
|
1291
|
+
return prop.split('.').reduce((/**
|
|
1292
|
+
* @param {?} acc
|
|
1293
|
+
* @param {?} part
|
|
1294
|
+
* @return {?}
|
|
1295
|
+
*/
|
|
1296
|
+
function (acc, part) { return acc && acc[part]; }), obj);
|
|
1297
|
+
});
|
|
1298
|
+
/**
|
|
1299
|
+
* Simple object check.
|
|
1300
|
+
*
|
|
1301
|
+
* isObject({a:1}) //=> true
|
|
1302
|
+
* isObject(1) //=> false
|
|
1303
|
+
*
|
|
1304
|
+
* @ignore
|
|
1305
|
+
* @type {?}
|
|
1306
|
+
*/
|
|
1307
|
+
var isObject$1 = (/**
|
|
1308
|
+
* @param {?} item
|
|
1309
|
+
* @return {?}
|
|
1310
|
+
*/
|
|
1311
|
+
function (item) {
|
|
1312
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
1313
|
+
});
|
|
1314
|
+
/**
|
|
1315
|
+
* Deep merge two objects.
|
|
1316
|
+
*
|
|
1317
|
+
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
1318
|
+
*
|
|
1319
|
+
* \@param base base object onto which `sources` will be applied
|
|
1320
|
+
* @type {?}
|
|
1321
|
+
*/
|
|
1322
|
+
var mergeDeep = (/**
|
|
1323
|
+
* @param {?} base
|
|
1324
|
+
* @param {...?} sources
|
|
1325
|
+
* @return {?}
|
|
1326
|
+
*/
|
|
1327
|
+
function (base) {
|
|
1328
|
+
var sources = [];
|
|
1329
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1330
|
+
sources[_i - 1] = arguments[_i];
|
|
1331
|
+
}
|
|
1332
|
+
var _a, _b;
|
|
1333
|
+
if (!sources.length)
|
|
1334
|
+
return base;
|
|
1335
|
+
/** @type {?} */
|
|
1336
|
+
var source = sources.shift();
|
|
1337
|
+
if (isObject$1(base) && isObject$1(source)) {
|
|
1338
|
+
for (var key in source) {
|
|
1339
|
+
if (isObject$1(source[key])) {
|
|
1340
|
+
if (!base[key])
|
|
1341
|
+
Object.assign(base, (_a = {}, _a[key] = {}, _a));
|
|
1342
|
+
mergeDeep(base[key], source[key]);
|
|
1343
|
+
}
|
|
1344
|
+
else {
|
|
1345
|
+
Object.assign(base, (_b = {}, _b[key] = source[key], _b));
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
return mergeDeep.apply(void 0, __spread([base], sources));
|
|
1350
|
+
});
|
|
1375
1351
|
|
|
1376
1352
|
/**
|
|
1377
1353
|
* @fileoverview added by tsickle
|
|
@@ -1804,6 +1780,15 @@
|
|
|
1804
1780
|
function InternalActions() {
|
|
1805
1781
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1806
1782
|
}
|
|
1783
|
+
/**
|
|
1784
|
+
* @return {?}
|
|
1785
|
+
*/
|
|
1786
|
+
InternalActions.prototype.ngOnDestroy = /**
|
|
1787
|
+
* @return {?}
|
|
1788
|
+
*/
|
|
1789
|
+
function () {
|
|
1790
|
+
this.complete();
|
|
1791
|
+
};
|
|
1807
1792
|
InternalActions.decorators = [
|
|
1808
1793
|
{ type: core.Injectable }
|
|
1809
1794
|
];
|
|
@@ -1819,15 +1804,21 @@
|
|
|
1819
1804
|
// This has to be `Observable<ActionContext>` in the v4. Because `InternalActions`
|
|
1820
1805
|
// is a `Subject<ActionContext>`. Leave it as `any` to avoid breaking changes
|
|
1821
1806
|
function Actions(internalActions$, internalExecutionStrategy) {
|
|
1822
|
-
|
|
1807
|
+
var _this = this;
|
|
1808
|
+
/** @type {?} */
|
|
1809
|
+
var sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
|
|
1810
|
+
// The `InternalActions` subject emits outside of the Angular zone.
|
|
1811
|
+
// We have to re-enter the Angular zone for any incoming consumer.
|
|
1812
|
+
// The `share()` operator reduces the number of change detections.
|
|
1813
|
+
// This would call leave only once for any stream emission across all active subscribers.
|
|
1814
|
+
operators.share());
|
|
1815
|
+
_this = _super.call(this, (/**
|
|
1823
1816
|
* @param {?} observer
|
|
1824
1817
|
* @return {?}
|
|
1825
1818
|
*/
|
|
1826
1819
|
function (observer) {
|
|
1827
1820
|
/** @type {?} */
|
|
1828
|
-
var childSubscription =
|
|
1829
|
-
.pipe(leaveNgxs(internalExecutionStrategy))
|
|
1830
|
-
.subscribe({
|
|
1821
|
+
var childSubscription = sharedInternalActions$.subscribe({
|
|
1831
1822
|
next: (/**
|
|
1832
1823
|
* @param {?} ctx
|
|
1833
1824
|
* @return {?}
|
|
@@ -1845,6 +1836,7 @@
|
|
|
1845
1836
|
});
|
|
1846
1837
|
observer.add(childSubscription);
|
|
1847
1838
|
})) || this;
|
|
1839
|
+
return _this;
|
|
1848
1840
|
}
|
|
1849
1841
|
Actions.decorators = [
|
|
1850
1842
|
{ type: core.Injectable }
|
|
@@ -1911,6 +1903,126 @@
|
|
|
1911
1903
|
})]));
|
|
1912
1904
|
}); });
|
|
1913
1905
|
|
|
1906
|
+
/**
|
|
1907
|
+
* @fileoverview added by tsickle
|
|
1908
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1909
|
+
*/
|
|
1910
|
+
/**
|
|
1911
|
+
* This operator is used for piping the observable result
|
|
1912
|
+
* from the `dispatch()`. It has a "smart" error handling
|
|
1913
|
+
* strategy that allows us to decide whether we propagate
|
|
1914
|
+
* errors to Angular's `ErrorHandler` or enable users to
|
|
1915
|
+
* handle them manually. We consider following cases:
|
|
1916
|
+
* 1) `store.dispatch()` (no subscribe) -> call `handleError()`
|
|
1917
|
+
* 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
|
|
1918
|
+
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
1919
|
+
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
1920
|
+
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
1921
|
+
* @template T
|
|
1922
|
+
* @param {?} internalErrorReporter
|
|
1923
|
+
* @param {?} ngxsExecutionStrategy
|
|
1924
|
+
* @return {?}
|
|
1925
|
+
*/
|
|
1926
|
+
function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
|
|
1927
|
+
return (/**
|
|
1928
|
+
* @param {?} source
|
|
1929
|
+
* @return {?}
|
|
1930
|
+
*/
|
|
1931
|
+
function (source) {
|
|
1932
|
+
/** @type {?} */
|
|
1933
|
+
var subscribed = false;
|
|
1934
|
+
source.subscribe({
|
|
1935
|
+
error: (/**
|
|
1936
|
+
* @param {?} error
|
|
1937
|
+
* @return {?}
|
|
1938
|
+
*/
|
|
1939
|
+
function (error) {
|
|
1940
|
+
// Do not trigger change detection for a microtask. This depends on the execution
|
|
1941
|
+
// strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
|
|
1942
|
+
// leaves the Angular zone.
|
|
1943
|
+
ngxsExecutionStrategy.enter((/**
|
|
1944
|
+
* @return {?}
|
|
1945
|
+
*/
|
|
1946
|
+
function () {
|
|
1947
|
+
return Promise.resolve().then((/**
|
|
1948
|
+
* @return {?}
|
|
1949
|
+
*/
|
|
1950
|
+
function () {
|
|
1951
|
+
if (!subscribed) {
|
|
1952
|
+
ngxsExecutionStrategy.leave((/**
|
|
1953
|
+
* @return {?}
|
|
1954
|
+
*/
|
|
1955
|
+
function () {
|
|
1956
|
+
return internalErrorReporter.reportErrorSafely(error);
|
|
1957
|
+
}));
|
|
1958
|
+
}
|
|
1959
|
+
}));
|
|
1960
|
+
}));
|
|
1961
|
+
})
|
|
1962
|
+
});
|
|
1963
|
+
return new rxjs.Observable((/**
|
|
1964
|
+
* @param {?} subscriber
|
|
1965
|
+
* @return {?}
|
|
1966
|
+
*/
|
|
1967
|
+
function (subscriber) {
|
|
1968
|
+
subscribed = true;
|
|
1969
|
+
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
1970
|
+
}));
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1973
|
+
var InternalErrorReporter = /** @class */ (function () {
|
|
1974
|
+
function InternalErrorReporter(_injector) {
|
|
1975
|
+
this._injector = _injector;
|
|
1976
|
+
/**
|
|
1977
|
+
* Will be set lazily to be backward compatible.
|
|
1978
|
+
*/
|
|
1979
|
+
this._errorHandler = (/** @type {?} */ (null));
|
|
1980
|
+
}
|
|
1981
|
+
/**
|
|
1982
|
+
* @param {?} error
|
|
1983
|
+
* @return {?}
|
|
1984
|
+
*/
|
|
1985
|
+
InternalErrorReporter.prototype.reportErrorSafely = /**
|
|
1986
|
+
* @param {?} error
|
|
1987
|
+
* @return {?}
|
|
1988
|
+
*/
|
|
1989
|
+
function (error) {
|
|
1990
|
+
if (this._errorHandler === null) {
|
|
1991
|
+
this._errorHandler = this._injector.get(core.ErrorHandler);
|
|
1992
|
+
}
|
|
1993
|
+
// The `try-catch` is used to avoid handling the error twice. Suppose we call
|
|
1994
|
+
// `handleError` which re-throws the error internally. The re-thrown error will
|
|
1995
|
+
// be caught by zone.js which will then get to the `zone.onError.emit()` and the
|
|
1996
|
+
// `onError` subscriber will call `handleError` again.
|
|
1997
|
+
try {
|
|
1998
|
+
this._errorHandler.handleError(error);
|
|
1999
|
+
}
|
|
2000
|
+
catch (_a) { }
|
|
2001
|
+
};
|
|
2002
|
+
InternalErrorReporter.decorators = [
|
|
2003
|
+
{ type: core.Injectable, args: [{ providedIn: 'root' },] }
|
|
2004
|
+
];
|
|
2005
|
+
/** @nocollapse */
|
|
2006
|
+
InternalErrorReporter.ctorParameters = function () { return [
|
|
2007
|
+
{ type: core.Injector }
|
|
2008
|
+
]; };
|
|
2009
|
+
/** @nocollapse */ InternalErrorReporter.ngInjectableDef = core.defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(core.inject(core.INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
|
|
2010
|
+
return InternalErrorReporter;
|
|
2011
|
+
}());
|
|
2012
|
+
if (false) {
|
|
2013
|
+
/**
|
|
2014
|
+
* Will be set lazily to be backward compatible.
|
|
2015
|
+
* @type {?}
|
|
2016
|
+
* @private
|
|
2017
|
+
*/
|
|
2018
|
+
InternalErrorReporter.prototype._errorHandler;
|
|
2019
|
+
/**
|
|
2020
|
+
* @type {?}
|
|
2021
|
+
* @private
|
|
2022
|
+
*/
|
|
2023
|
+
InternalErrorReporter.prototype._injector;
|
|
2024
|
+
}
|
|
2025
|
+
|
|
1914
2026
|
/**
|
|
1915
2027
|
* @fileoverview added by tsickle
|
|
1916
2028
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -2043,13 +2155,13 @@
|
|
|
2043
2155
|
return InternalDispatchedActionResults;
|
|
2044
2156
|
}(rxjs.Subject));
|
|
2045
2157
|
var InternalDispatcher = /** @class */ (function () {
|
|
2046
|
-
function InternalDispatcher(
|
|
2047
|
-
this._injector = _injector;
|
|
2158
|
+
function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
|
|
2048
2159
|
this._actions = _actions;
|
|
2049
2160
|
this._actionResults = _actionResults;
|
|
2050
2161
|
this._pluginManager = _pluginManager;
|
|
2051
2162
|
this._stateStream = _stateStream;
|
|
2052
2163
|
this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
|
|
2164
|
+
this._internalErrorReporter = _internalErrorReporter;
|
|
2053
2165
|
}
|
|
2054
2166
|
/**
|
|
2055
2167
|
* Dispatches event(s).
|
|
@@ -2073,26 +2185,7 @@
|
|
|
2073
2185
|
function () {
|
|
2074
2186
|
return _this.dispatchByEvents(actionOrActions);
|
|
2075
2187
|
}));
|
|
2076
|
-
result.
|
|
2077
|
-
error: (/**
|
|
2078
|
-
* @param {?} error
|
|
2079
|
-
* @return {?}
|
|
2080
|
-
*/
|
|
2081
|
-
function (error) {
|
|
2082
|
-
return _this._ngxsExecutionStrategy.leave((/**
|
|
2083
|
-
* @return {?}
|
|
2084
|
-
*/
|
|
2085
|
-
function () {
|
|
2086
|
-
try {
|
|
2087
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
2088
|
-
_this._errorHandler = _this._errorHandler || _this._injector.get(core.ErrorHandler);
|
|
2089
|
-
_this._errorHandler.handleError(error);
|
|
2090
|
-
}
|
|
2091
|
-
catch (_a) { }
|
|
2092
|
-
}));
|
|
2093
|
-
})
|
|
2094
|
-
});
|
|
2095
|
-
return result.pipe(leaveNgxs(this._ngxsExecutionStrategy));
|
|
2188
|
+
return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
|
|
2096
2189
|
};
|
|
2097
2190
|
/**
|
|
2098
2191
|
* @private
|
|
@@ -2217,26 +2310,16 @@
|
|
|
2217
2310
|
];
|
|
2218
2311
|
/** @nocollapse */
|
|
2219
2312
|
InternalDispatcher.ctorParameters = function () { return [
|
|
2220
|
-
{ type: core.Injector },
|
|
2221
2313
|
{ type: InternalActions },
|
|
2222
2314
|
{ type: InternalDispatchedActionResults },
|
|
2223
2315
|
{ type: PluginManager },
|
|
2224
2316
|
{ type: StateStream },
|
|
2225
|
-
{ type: InternalNgxsExecutionStrategy }
|
|
2317
|
+
{ type: InternalNgxsExecutionStrategy },
|
|
2318
|
+
{ type: InternalErrorReporter }
|
|
2226
2319
|
]; };
|
|
2227
2320
|
return InternalDispatcher;
|
|
2228
2321
|
}());
|
|
2229
2322
|
if (false) {
|
|
2230
|
-
/**
|
|
2231
|
-
* @type {?}
|
|
2232
|
-
* @private
|
|
2233
|
-
*/
|
|
2234
|
-
InternalDispatcher.prototype._errorHandler;
|
|
2235
|
-
/**
|
|
2236
|
-
* @type {?}
|
|
2237
|
-
* @private
|
|
2238
|
-
*/
|
|
2239
|
-
InternalDispatcher.prototype._injector;
|
|
2240
2323
|
/**
|
|
2241
2324
|
* @type {?}
|
|
2242
2325
|
* @private
|
|
@@ -2262,6 +2345,11 @@
|
|
|
2262
2345
|
* @private
|
|
2263
2346
|
*/
|
|
2264
2347
|
InternalDispatcher.prototype._ngxsExecutionStrategy;
|
|
2348
|
+
/**
|
|
2349
|
+
* @type {?}
|
|
2350
|
+
* @private
|
|
2351
|
+
*/
|
|
2352
|
+
InternalDispatcher.prototype._internalErrorReporter;
|
|
2265
2353
|
}
|
|
2266
2354
|
|
|
2267
2355
|
/**
|
|
@@ -2503,16 +2591,6 @@
|
|
|
2503
2591
|
function setStateValue(currentAppState, newValue) {
|
|
2504
2592
|
/** @type {?} */
|
|
2505
2593
|
var newAppState = setValue(currentAppState, mappedStore.path, newValue);
|
|
2506
|
-
/** @type {?} */
|
|
2507
|
-
var instance = mappedStore.instance;
|
|
2508
|
-
if (instance.ngxsOnChanges) {
|
|
2509
|
-
/** @type {?} */
|
|
2510
|
-
var change = getStateDiffChanges(mappedStore, {
|
|
2511
|
-
currentAppState: currentAppState,
|
|
2512
|
-
newAppState: newAppState
|
|
2513
|
-
});
|
|
2514
|
-
instance.ngxsOnChanges(change);
|
|
2515
|
-
}
|
|
2516
2594
|
root.setState(newAppState);
|
|
2517
2595
|
return newAppState;
|
|
2518
2596
|
// In doing this refactoring I noticed that there is a 'bug' where the
|
|
@@ -2826,7 +2904,7 @@
|
|
|
2826
2904
|
if (Array.isArray(defaults)) {
|
|
2827
2905
|
value = defaults.slice();
|
|
2828
2906
|
}
|
|
2829
|
-
else if (isObject
|
|
2907
|
+
else if (isObject(defaults)) {
|
|
2830
2908
|
value = __assign({}, defaults);
|
|
2831
2909
|
}
|
|
2832
2910
|
else if (defaults === undefined) {
|
|
@@ -3041,7 +3119,7 @@
|
|
|
3041
3119
|
if (result instanceof Promise) {
|
|
3042
3120
|
result = rxjs.from(result);
|
|
3043
3121
|
}
|
|
3044
|
-
if (
|
|
3122
|
+
if (rxjs.isObservable(result)) {
|
|
3045
3123
|
// If this observable has been completed w/o emitting
|
|
3046
3124
|
// any value then we wouldn't want to complete the whole chain
|
|
3047
3125
|
// of actions. Since if any observable completes then
|
|
@@ -3058,7 +3136,7 @@
|
|
|
3058
3136
|
if (value instanceof Promise) {
|
|
3059
3137
|
return rxjs.from(value);
|
|
3060
3138
|
}
|
|
3061
|
-
if (
|
|
3139
|
+
if (rxjs.isObservable(value)) {
|
|
3062
3140
|
return value;
|
|
3063
3141
|
}
|
|
3064
3142
|
return rxjs.of(value);
|
|
@@ -3151,289 +3229,120 @@
|
|
|
3151
3229
|
*/
|
|
3152
3230
|
StateFactory.prototype.addRuntimeInfoToMeta = /**
|
|
3153
3231
|
* @private
|
|
3154
|
-
* @param {?} meta
|
|
3155
|
-
* @param {?} path
|
|
3156
|
-
* @return {?}
|
|
3157
|
-
*/
|
|
3158
|
-
function (meta, path) {
|
|
3159
|
-
this.statePaths[(/** @type {?} */ (meta.name))] = path;
|
|
3160
|
-
// TODO: v4 - we plan to get rid of the path property because it is non-deterministic
|
|
3161
|
-
// we can do this when we get rid of the incorrectly exposed getStoreMetadata
|
|
3162
|
-
// We will need to come up with an alternative in v4 because this is used by many plugins
|
|
3163
|
-
meta.path = path;
|
|
3164
|
-
};
|
|
3165
|
-
/**
|
|
3166
|
-
* @description
|
|
3167
|
-
* the method checks if the state has already been added to the tree
|
|
3168
|
-
* and completed the life cycle
|
|
3169
|
-
* @param name
|
|
3170
|
-
* @param path
|
|
3171
|
-
*/
|
|
3172
|
-
/**
|
|
3173
|
-
* \@description
|
|
3174
|
-
* the method checks if the state has already been added to the tree
|
|
3175
|
-
* and completed the life cycle
|
|
3176
|
-
* @private
|
|
3177
|
-
* @param {?} name
|
|
3178
|
-
* @param {?} path
|
|
3179
|
-
* @return {?}
|
|
3180
|
-
*/
|
|
3181
|
-
StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
|
|
3182
|
-
* \@description
|
|
3183
|
-
* the method checks if the state has already been added to the tree
|
|
3184
|
-
* and completed the life cycle
|
|
3185
|
-
* @private
|
|
3186
|
-
* @param {?} name
|
|
3187
|
-
* @param {?} path
|
|
3188
|
-
* @return {?}
|
|
3189
|
-
*/
|
|
3190
|
-
function (name, path) {
|
|
3191
|
-
/** @type {?} */
|
|
3192
|
-
var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
|
|
3193
|
-
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
3194
|
-
};
|
|
3195
|
-
StateFactory.decorators = [
|
|
3196
|
-
{ type: core.Injectable }
|
|
3197
|
-
];
|
|
3198
|
-
/** @nocollapse */
|
|
3199
|
-
StateFactory.ctorParameters = function () { return [
|
|
3200
|
-
{ type: core.Injector },
|
|
3201
|
-
{ type: NgxsConfig },
|
|
3202
|
-
{ type: StateFactory, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
|
|
3203
|
-
{ type: InternalActions },
|
|
3204
|
-
{ type: InternalDispatchedActionResults },
|
|
3205
|
-
{ type: StateContextFactory },
|
|
3206
|
-
{ type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [internals.INITIAL_STATE_TOKEN,] }] }
|
|
3207
|
-
]; };
|
|
3208
|
-
return StateFactory;
|
|
3209
|
-
}());
|
|
3210
|
-
if (false) {
|
|
3211
|
-
/**
|
|
3212
|
-
* @type {?}
|
|
3213
|
-
* @private
|
|
3214
|
-
*/
|
|
3215
|
-
StateFactory.prototype._actionsSubscription;
|
|
3216
|
-
/**
|
|
3217
|
-
* @type {?}
|
|
3218
|
-
* @private
|
|
3219
|
-
*/
|
|
3220
|
-
StateFactory.prototype._states;
|
|
3221
|
-
/**
|
|
3222
|
-
* @type {?}
|
|
3223
|
-
* @private
|
|
3224
|
-
*/
|
|
3225
|
-
StateFactory.prototype._statesByName;
|
|
3226
|
-
/**
|
|
3227
|
-
* @type {?}
|
|
3228
|
-
* @private
|
|
3229
|
-
*/
|
|
3230
|
-
StateFactory.prototype._statePaths;
|
|
3231
|
-
/** @type {?} */
|
|
3232
|
-
StateFactory.prototype.getRuntimeSelectorContext;
|
|
3233
|
-
/**
|
|
3234
|
-
* @type {?}
|
|
3235
|
-
* @private
|
|
3236
|
-
*/
|
|
3237
|
-
StateFactory.prototype._injector;
|
|
3238
|
-
/**
|
|
3239
|
-
* @type {?}
|
|
3240
|
-
* @private
|
|
3241
|
-
*/
|
|
3242
|
-
StateFactory.prototype._config;
|
|
3243
|
-
/**
|
|
3244
|
-
* @type {?}
|
|
3245
|
-
* @private
|
|
3246
|
-
*/
|
|
3247
|
-
StateFactory.prototype._parentFactory;
|
|
3248
|
-
/**
|
|
3249
|
-
* @type {?}
|
|
3250
|
-
* @private
|
|
3251
|
-
*/
|
|
3252
|
-
StateFactory.prototype._actions;
|
|
3253
|
-
/**
|
|
3254
|
-
* @type {?}
|
|
3255
|
-
* @private
|
|
3256
|
-
*/
|
|
3257
|
-
StateFactory.prototype._actionResults;
|
|
3258
|
-
/**
|
|
3259
|
-
* @type {?}
|
|
3260
|
-
* @private
|
|
3261
|
-
*/
|
|
3262
|
-
StateFactory.prototype._stateContextFactory;
|
|
3263
|
-
/**
|
|
3264
|
-
* @type {?}
|
|
3265
|
-
* @private
|
|
3266
|
-
*/
|
|
3267
|
-
StateFactory.prototype._initialState;
|
|
3268
|
-
}
|
|
3269
|
-
|
|
3270
|
-
/**
|
|
3271
|
-
* @fileoverview added by tsickle
|
|
3272
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3273
|
-
*/
|
|
3274
|
-
var LifecycleStateManager = /** @class */ (function () {
|
|
3275
|
-
function LifecycleStateManager(internalStateOperations, stateContextFactory, bootstrapper) {
|
|
3276
|
-
this.internalStateOperations = internalStateOperations;
|
|
3277
|
-
this.stateContextFactory = stateContextFactory;
|
|
3278
|
-
this.bootstrapper = bootstrapper;
|
|
3279
|
-
}
|
|
3280
|
-
/**
|
|
3281
|
-
* @template T
|
|
3282
|
-
* @param {?} action
|
|
3283
|
-
* @param {?} results
|
|
3284
|
-
* @return {?}
|
|
3285
|
-
*/
|
|
3286
|
-
LifecycleStateManager.prototype.ngxsBootstrap = /**
|
|
3287
|
-
* @template T
|
|
3288
|
-
* @param {?} action
|
|
3289
|
-
* @param {?} results
|
|
3290
|
-
* @return {?}
|
|
3291
|
-
*/
|
|
3292
|
-
function (action, results) {
|
|
3293
|
-
var _this = this;
|
|
3294
|
-
this.internalStateOperations
|
|
3295
|
-
.getRootStateOperations()
|
|
3296
|
-
.dispatch(action)
|
|
3297
|
-
.pipe(operators.filter((/**
|
|
3298
|
-
* @return {?}
|
|
3299
|
-
*/
|
|
3300
|
-
function () { return !!results; })), operators.tap((/**
|
|
3301
|
-
* @return {?}
|
|
3302
|
-
*/
|
|
3303
|
-
function () { return _this.invokeInit((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
|
|
3304
|
-
* @return {?}
|
|
3305
|
-
*/
|
|
3306
|
-
function () { return _this.bootstrapper.appBootstrapped$; })), operators.filter((/**
|
|
3307
|
-
* @param {?} appBootstrapped
|
|
3308
|
-
* @return {?}
|
|
3309
|
-
*/
|
|
3310
|
-
function (appBootstrapped) { return !!appBootstrapped; })))
|
|
3311
|
-
.subscribe((/**
|
|
3312
|
-
* @return {?}
|
|
3313
|
-
*/
|
|
3314
|
-
function () { return _this.invokeBootstrap((/** @type {?} */ (results)).states); }));
|
|
3315
|
-
};
|
|
3316
|
-
/**
|
|
3317
|
-
* Invoke the init function on the states.
|
|
3318
|
-
*/
|
|
3319
|
-
/**
|
|
3320
|
-
* Invoke the init function on the states.
|
|
3321
|
-
* @param {?} mappedStores
|
|
3322
|
-
* @return {?}
|
|
3323
|
-
*/
|
|
3324
|
-
LifecycleStateManager.prototype.invokeInit = /**
|
|
3325
|
-
* Invoke the init function on the states.
|
|
3326
|
-
* @param {?} mappedStores
|
|
3327
|
-
* @return {?}
|
|
3328
|
-
*/
|
|
3329
|
-
function (mappedStores) {
|
|
3330
|
-
var e_1, _a;
|
|
3331
|
-
try {
|
|
3332
|
-
for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
|
|
3333
|
-
var mappedStore = mappedStores_1_1.value;
|
|
3334
|
-
/** @type {?} */
|
|
3335
|
-
var instance = mappedStore.instance;
|
|
3336
|
-
if (instance.ngxsOnChanges) {
|
|
3337
|
-
/** @type {?} */
|
|
3338
|
-
var currentAppState = {};
|
|
3339
|
-
/** @type {?} */
|
|
3340
|
-
var newAppState = this.internalStateOperations
|
|
3341
|
-
.getRootStateOperations()
|
|
3342
|
-
.getState();
|
|
3343
|
-
/** @type {?} */
|
|
3344
|
-
var firstDiffChange = getStateDiffChanges(mappedStore, {
|
|
3345
|
-
currentAppState: currentAppState,
|
|
3346
|
-
newAppState: newAppState
|
|
3347
|
-
});
|
|
3348
|
-
instance.ngxsOnChanges(firstDiffChange);
|
|
3349
|
-
}
|
|
3350
|
-
if (instance.ngxsOnInit) {
|
|
3351
|
-
instance.ngxsOnInit(this.getStateContext(mappedStore));
|
|
3352
|
-
}
|
|
3353
|
-
mappedStore.isInitialised = true;
|
|
3354
|
-
}
|
|
3355
|
-
}
|
|
3356
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3357
|
-
finally {
|
|
3358
|
-
try {
|
|
3359
|
-
if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
|
|
3360
|
-
}
|
|
3361
|
-
finally { if (e_1) throw e_1.error; }
|
|
3362
|
-
}
|
|
3363
|
-
};
|
|
3364
|
-
/**
|
|
3365
|
-
* Invoke the bootstrap function on the states.
|
|
3366
|
-
*/
|
|
3367
|
-
/**
|
|
3368
|
-
* Invoke the bootstrap function on the states.
|
|
3369
|
-
* @param {?} mappedStores
|
|
3370
|
-
* @return {?}
|
|
3371
|
-
*/
|
|
3372
|
-
LifecycleStateManager.prototype.invokeBootstrap = /**
|
|
3373
|
-
* Invoke the bootstrap function on the states.
|
|
3374
|
-
* @param {?} mappedStores
|
|
3375
|
-
* @return {?}
|
|
3376
|
-
*/
|
|
3377
|
-
function (mappedStores) {
|
|
3378
|
-
var e_2, _a;
|
|
3379
|
-
try {
|
|
3380
|
-
for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
|
|
3381
|
-
var mappedStore = mappedStores_2_1.value;
|
|
3382
|
-
/** @type {?} */
|
|
3383
|
-
var instance = mappedStore.instance;
|
|
3384
|
-
if (instance.ngxsAfterBootstrap) {
|
|
3385
|
-
instance.ngxsAfterBootstrap(this.getStateContext(mappedStore));
|
|
3386
|
-
}
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3390
|
-
finally {
|
|
3391
|
-
try {
|
|
3392
|
-
if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
|
|
3393
|
-
}
|
|
3394
|
-
finally { if (e_2) throw e_2.error; }
|
|
3395
|
-
}
|
|
3232
|
+
* @param {?} meta
|
|
3233
|
+
* @param {?} path
|
|
3234
|
+
* @return {?}
|
|
3235
|
+
*/
|
|
3236
|
+
function (meta, path) {
|
|
3237
|
+
this.statePaths[(/** @type {?} */ (meta.name))] = path;
|
|
3238
|
+
// TODO: v4 - we plan to get rid of the path property because it is non-deterministic
|
|
3239
|
+
// we can do this when we get rid of the incorrectly exposed getStoreMetadata
|
|
3240
|
+
// We will need to come up with an alternative in v4 because this is used by many plugins
|
|
3241
|
+
meta.path = path;
|
|
3396
3242
|
};
|
|
3397
3243
|
/**
|
|
3244
|
+
* @description
|
|
3245
|
+
* the method checks if the state has already been added to the tree
|
|
3246
|
+
* and completed the life cycle
|
|
3247
|
+
* @param name
|
|
3248
|
+
* @param path
|
|
3249
|
+
*/
|
|
3250
|
+
/**
|
|
3251
|
+
* \@description
|
|
3252
|
+
* the method checks if the state has already been added to the tree
|
|
3253
|
+
* and completed the life cycle
|
|
3398
3254
|
* @private
|
|
3399
|
-
* @param {?}
|
|
3255
|
+
* @param {?} name
|
|
3256
|
+
* @param {?} path
|
|
3400
3257
|
* @return {?}
|
|
3401
3258
|
*/
|
|
3402
|
-
|
|
3259
|
+
StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
|
|
3260
|
+
* \@description
|
|
3261
|
+
* the method checks if the state has already been added to the tree
|
|
3262
|
+
* and completed the life cycle
|
|
3403
3263
|
* @private
|
|
3404
|
-
* @param {?}
|
|
3264
|
+
* @param {?} name
|
|
3265
|
+
* @param {?} path
|
|
3405
3266
|
* @return {?}
|
|
3406
3267
|
*/
|
|
3407
|
-
function (
|
|
3408
|
-
|
|
3268
|
+
function (name, path) {
|
|
3269
|
+
/** @type {?} */
|
|
3270
|
+
var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
|
|
3271
|
+
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
3409
3272
|
};
|
|
3410
|
-
|
|
3273
|
+
StateFactory.decorators = [
|
|
3411
3274
|
{ type: core.Injectable }
|
|
3412
3275
|
];
|
|
3413
3276
|
/** @nocollapse */
|
|
3414
|
-
|
|
3415
|
-
{ type:
|
|
3277
|
+
StateFactory.ctorParameters = function () { return [
|
|
3278
|
+
{ type: core.Injector },
|
|
3279
|
+
{ type: NgxsConfig },
|
|
3280
|
+
{ type: StateFactory, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
|
|
3281
|
+
{ type: InternalActions },
|
|
3282
|
+
{ type: InternalDispatchedActionResults },
|
|
3416
3283
|
{ type: StateContextFactory },
|
|
3417
|
-
{ type: internals.
|
|
3284
|
+
{ type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [internals.INITIAL_STATE_TOKEN,] }] }
|
|
3418
3285
|
]; };
|
|
3419
|
-
return
|
|
3286
|
+
return StateFactory;
|
|
3420
3287
|
}());
|
|
3421
3288
|
if (false) {
|
|
3422
3289
|
/**
|
|
3423
3290
|
* @type {?}
|
|
3424
3291
|
* @private
|
|
3425
3292
|
*/
|
|
3426
|
-
|
|
3293
|
+
StateFactory.prototype._actionsSubscription;
|
|
3294
|
+
/**
|
|
3295
|
+
* @type {?}
|
|
3296
|
+
* @private
|
|
3297
|
+
*/
|
|
3298
|
+
StateFactory.prototype._states;
|
|
3299
|
+
/**
|
|
3300
|
+
* @type {?}
|
|
3301
|
+
* @private
|
|
3302
|
+
*/
|
|
3303
|
+
StateFactory.prototype._statesByName;
|
|
3304
|
+
/**
|
|
3305
|
+
* @type {?}
|
|
3306
|
+
* @private
|
|
3307
|
+
*/
|
|
3308
|
+
StateFactory.prototype._statePaths;
|
|
3309
|
+
/** @type {?} */
|
|
3310
|
+
StateFactory.prototype.getRuntimeSelectorContext;
|
|
3311
|
+
/**
|
|
3312
|
+
* @type {?}
|
|
3313
|
+
* @private
|
|
3314
|
+
*/
|
|
3315
|
+
StateFactory.prototype._injector;
|
|
3316
|
+
/**
|
|
3317
|
+
* @type {?}
|
|
3318
|
+
* @private
|
|
3319
|
+
*/
|
|
3320
|
+
StateFactory.prototype._config;
|
|
3321
|
+
/**
|
|
3322
|
+
* @type {?}
|
|
3323
|
+
* @private
|
|
3324
|
+
*/
|
|
3325
|
+
StateFactory.prototype._parentFactory;
|
|
3326
|
+
/**
|
|
3327
|
+
* @type {?}
|
|
3328
|
+
* @private
|
|
3329
|
+
*/
|
|
3330
|
+
StateFactory.prototype._actions;
|
|
3331
|
+
/**
|
|
3332
|
+
* @type {?}
|
|
3333
|
+
* @private
|
|
3334
|
+
*/
|
|
3335
|
+
StateFactory.prototype._actionResults;
|
|
3427
3336
|
/**
|
|
3428
3337
|
* @type {?}
|
|
3429
3338
|
* @private
|
|
3430
3339
|
*/
|
|
3431
|
-
|
|
3340
|
+
StateFactory.prototype._stateContextFactory;
|
|
3432
3341
|
/**
|
|
3433
3342
|
* @type {?}
|
|
3434
3343
|
* @private
|
|
3435
3344
|
*/
|
|
3436
|
-
|
|
3345
|
+
StateFactory.prototype._initialState;
|
|
3437
3346
|
}
|
|
3438
3347
|
|
|
3439
3348
|
/**
|
|
@@ -3890,6 +3799,218 @@
|
|
|
3890
3799
|
Store.prototype._stateFactory;
|
|
3891
3800
|
}
|
|
3892
3801
|
|
|
3802
|
+
/**
|
|
3803
|
+
* @fileoverview added by tsickle
|
|
3804
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3805
|
+
*/
|
|
3806
|
+
var LifecycleStateManager = /** @class */ (function () {
|
|
3807
|
+
function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3808
|
+
this._store = _store;
|
|
3809
|
+
this._internalErrorReporter = _internalErrorReporter;
|
|
3810
|
+
this._internalStateOperations = _internalStateOperations;
|
|
3811
|
+
this._stateContextFactory = _stateContextFactory;
|
|
3812
|
+
this._bootstrapper = _bootstrapper;
|
|
3813
|
+
this._destroy$ = new rxjs.Subject();
|
|
3814
|
+
}
|
|
3815
|
+
/**
|
|
3816
|
+
* @return {?}
|
|
3817
|
+
*/
|
|
3818
|
+
LifecycleStateManager.prototype.ngOnDestroy = /**
|
|
3819
|
+
* @return {?}
|
|
3820
|
+
*/
|
|
3821
|
+
function () {
|
|
3822
|
+
this._destroy$.next();
|
|
3823
|
+
};
|
|
3824
|
+
/**
|
|
3825
|
+
* @template T
|
|
3826
|
+
* @param {?} action
|
|
3827
|
+
* @param {?} results
|
|
3828
|
+
* @return {?}
|
|
3829
|
+
*/
|
|
3830
|
+
LifecycleStateManager.prototype.ngxsBootstrap = /**
|
|
3831
|
+
* @template T
|
|
3832
|
+
* @param {?} action
|
|
3833
|
+
* @param {?} results
|
|
3834
|
+
* @return {?}
|
|
3835
|
+
*/
|
|
3836
|
+
function (action, results) {
|
|
3837
|
+
var _this = this;
|
|
3838
|
+
this._internalStateOperations
|
|
3839
|
+
.getRootStateOperations()
|
|
3840
|
+
.dispatch(action)
|
|
3841
|
+
.pipe(operators.filter((/**
|
|
3842
|
+
* @return {?}
|
|
3843
|
+
*/
|
|
3844
|
+
function () { return !!results; })), operators.tap((/**
|
|
3845
|
+
* @return {?}
|
|
3846
|
+
*/
|
|
3847
|
+
function () { return _this._invokeInitOnStates((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
|
|
3848
|
+
* @return {?}
|
|
3849
|
+
*/
|
|
3850
|
+
function () { return _this._bootstrapper.appBootstrapped$; })), operators.filter((/**
|
|
3851
|
+
* @param {?} appBootstrapped
|
|
3852
|
+
* @return {?}
|
|
3853
|
+
*/
|
|
3854
|
+
function (appBootstrapped) { return !!appBootstrapped; })), operators.catchError((/**
|
|
3855
|
+
* @param {?} error
|
|
3856
|
+
* @return {?}
|
|
3857
|
+
*/
|
|
3858
|
+
function (error) {
|
|
3859
|
+
// The `SafeSubscriber` (which is used by most RxJS operators) re-throws
|
|
3860
|
+
// errors asynchronously (`setTimeout(() => { throw error })`). This might
|
|
3861
|
+
// break existing user's code or unit tests. We catch the error manually to
|
|
3862
|
+
// be backward compatible with the old behavior.
|
|
3863
|
+
_this._internalErrorReporter.reportErrorSafely(error);
|
|
3864
|
+
return rxjs.EMPTY;
|
|
3865
|
+
})), operators.takeUntil(this._destroy$))
|
|
3866
|
+
.subscribe((/**
|
|
3867
|
+
* @return {?}
|
|
3868
|
+
*/
|
|
3869
|
+
function () { return _this._invokeBootstrapOnStates((/** @type {?} */ (results)).states); }));
|
|
3870
|
+
};
|
|
3871
|
+
/**
|
|
3872
|
+
* @private
|
|
3873
|
+
* @param {?} mappedStores
|
|
3874
|
+
* @return {?}
|
|
3875
|
+
*/
|
|
3876
|
+
LifecycleStateManager.prototype._invokeInitOnStates = /**
|
|
3877
|
+
* @private
|
|
3878
|
+
* @param {?} mappedStores
|
|
3879
|
+
* @return {?}
|
|
3880
|
+
*/
|
|
3881
|
+
function (mappedStores) {
|
|
3882
|
+
var e_1, _a;
|
|
3883
|
+
var _loop_1 = function (mappedStore) {
|
|
3884
|
+
/** @type {?} */
|
|
3885
|
+
var instance = mappedStore.instance;
|
|
3886
|
+
if (instance.ngxsOnChanges) {
|
|
3887
|
+
this_1._store
|
|
3888
|
+
.select((/**
|
|
3889
|
+
* @param {?} state
|
|
3890
|
+
* @return {?}
|
|
3891
|
+
*/
|
|
3892
|
+
function (state) { return getValue(state, mappedStore.path); }))
|
|
3893
|
+
.pipe(operators.startWith(undefined), operators.pairwise(), operators.takeUntil(this_1._destroy$))
|
|
3894
|
+
.subscribe((/**
|
|
3895
|
+
* @param {?} __0
|
|
3896
|
+
* @return {?}
|
|
3897
|
+
*/
|
|
3898
|
+
function (_a) {
|
|
3899
|
+
var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
|
|
3900
|
+
/** @type {?} */
|
|
3901
|
+
var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
|
|
3902
|
+
(/** @type {?} */ (instance.ngxsOnChanges))(change);
|
|
3903
|
+
}));
|
|
3904
|
+
}
|
|
3905
|
+
if (instance.ngxsOnInit) {
|
|
3906
|
+
instance.ngxsOnInit(this_1._getStateContext(mappedStore));
|
|
3907
|
+
}
|
|
3908
|
+
mappedStore.isInitialised = true;
|
|
3909
|
+
};
|
|
3910
|
+
var this_1 = this;
|
|
3911
|
+
try {
|
|
3912
|
+
for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
|
|
3913
|
+
var mappedStore = mappedStores_1_1.value;
|
|
3914
|
+
_loop_1(mappedStore);
|
|
3915
|
+
}
|
|
3916
|
+
}
|
|
3917
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3918
|
+
finally {
|
|
3919
|
+
try {
|
|
3920
|
+
if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
|
|
3921
|
+
}
|
|
3922
|
+
finally { if (e_1) throw e_1.error; }
|
|
3923
|
+
}
|
|
3924
|
+
};
|
|
3925
|
+
/**
|
|
3926
|
+
* @private
|
|
3927
|
+
* @param {?} mappedStores
|
|
3928
|
+
* @return {?}
|
|
3929
|
+
*/
|
|
3930
|
+
LifecycleStateManager.prototype._invokeBootstrapOnStates = /**
|
|
3931
|
+
* @private
|
|
3932
|
+
* @param {?} mappedStores
|
|
3933
|
+
* @return {?}
|
|
3934
|
+
*/
|
|
3935
|
+
function (mappedStores) {
|
|
3936
|
+
var e_2, _a;
|
|
3937
|
+
try {
|
|
3938
|
+
for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
|
|
3939
|
+
var mappedStore = mappedStores_2_1.value;
|
|
3940
|
+
/** @type {?} */
|
|
3941
|
+
var instance = mappedStore.instance;
|
|
3942
|
+
if (instance.ngxsAfterBootstrap) {
|
|
3943
|
+
instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
|
|
3944
|
+
}
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3948
|
+
finally {
|
|
3949
|
+
try {
|
|
3950
|
+
if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
|
|
3951
|
+
}
|
|
3952
|
+
finally { if (e_2) throw e_2.error; }
|
|
3953
|
+
}
|
|
3954
|
+
};
|
|
3955
|
+
/**
|
|
3956
|
+
* @private
|
|
3957
|
+
* @param {?} mappedStore
|
|
3958
|
+
* @return {?}
|
|
3959
|
+
*/
|
|
3960
|
+
LifecycleStateManager.prototype._getStateContext = /**
|
|
3961
|
+
* @private
|
|
3962
|
+
* @param {?} mappedStore
|
|
3963
|
+
* @return {?}
|
|
3964
|
+
*/
|
|
3965
|
+
function (mappedStore) {
|
|
3966
|
+
return this._stateContextFactory.createStateContext(mappedStore);
|
|
3967
|
+
};
|
|
3968
|
+
LifecycleStateManager.decorators = [
|
|
3969
|
+
{ type: core.Injectable }
|
|
3970
|
+
];
|
|
3971
|
+
/** @nocollapse */
|
|
3972
|
+
LifecycleStateManager.ctorParameters = function () { return [
|
|
3973
|
+
{ type: Store },
|
|
3974
|
+
{ type: InternalErrorReporter },
|
|
3975
|
+
{ type: InternalStateOperations },
|
|
3976
|
+
{ type: StateContextFactory },
|
|
3977
|
+
{ type: internals.NgxsBootstrapper }
|
|
3978
|
+
]; };
|
|
3979
|
+
return LifecycleStateManager;
|
|
3980
|
+
}());
|
|
3981
|
+
if (false) {
|
|
3982
|
+
/**
|
|
3983
|
+
* @type {?}
|
|
3984
|
+
* @private
|
|
3985
|
+
*/
|
|
3986
|
+
LifecycleStateManager.prototype._destroy$;
|
|
3987
|
+
/**
|
|
3988
|
+
* @type {?}
|
|
3989
|
+
* @private
|
|
3990
|
+
*/
|
|
3991
|
+
LifecycleStateManager.prototype._store;
|
|
3992
|
+
/**
|
|
3993
|
+
* @type {?}
|
|
3994
|
+
* @private
|
|
3995
|
+
*/
|
|
3996
|
+
LifecycleStateManager.prototype._internalErrorReporter;
|
|
3997
|
+
/**
|
|
3998
|
+
* @type {?}
|
|
3999
|
+
* @private
|
|
4000
|
+
*/
|
|
4001
|
+
LifecycleStateManager.prototype._internalStateOperations;
|
|
4002
|
+
/**
|
|
4003
|
+
* @type {?}
|
|
4004
|
+
* @private
|
|
4005
|
+
*/
|
|
4006
|
+
LifecycleStateManager.prototype._stateContextFactory;
|
|
4007
|
+
/**
|
|
4008
|
+
* @type {?}
|
|
4009
|
+
* @private
|
|
4010
|
+
*/
|
|
4011
|
+
LifecycleStateManager.prototype._bootstrapper;
|
|
4012
|
+
}
|
|
4013
|
+
|
|
3893
4014
|
/**
|
|
3894
4015
|
* @fileoverview added by tsickle
|
|
3895
4016
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -4739,13 +4860,14 @@
|
|
|
4739
4860
|
exports.ɵo = InternalStateOperations;
|
|
4740
4861
|
exports.ɵp = PluginManager;
|
|
4741
4862
|
exports.ɵq = InternalNgxsExecutionStrategy;
|
|
4742
|
-
exports.ɵr =
|
|
4743
|
-
exports.ɵ
|
|
4744
|
-
exports.ɵu =
|
|
4745
|
-
exports.ɵv =
|
|
4746
|
-
exports.ɵw =
|
|
4747
|
-
exports.ɵx =
|
|
4748
|
-
exports.ɵy =
|
|
4863
|
+
exports.ɵr = InternalErrorReporter;
|
|
4864
|
+
exports.ɵs = SelectFactory;
|
|
4865
|
+
exports.ɵu = ensureStoreMetadata;
|
|
4866
|
+
exports.ɵv = getStoreMetadata;
|
|
4867
|
+
exports.ɵw = ensureSelectorMetadata;
|
|
4868
|
+
exports.ɵx = getSelectorMetadata;
|
|
4869
|
+
exports.ɵy = LifecycleStateManager;
|
|
4870
|
+
exports.ɵz = NgxsFeatureModule;
|
|
4749
4871
|
|
|
4750
4872
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4751
4873
|
|