@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
package/fesm5/ngxs-store.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { __assign, __spread, __extends, __values } from 'tslib';
|
|
2
|
-
import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal,
|
|
1
|
+
import { __assign, __spread, __extends, __values, __read } from 'tslib';
|
|
2
|
+
import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, ErrorHandler, Injector, Optional, SkipSelf, ɵivyEnabled, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
|
|
3
3
|
import { memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
|
|
4
4
|
import { isPlatformServer } from '@angular/common';
|
|
5
|
-
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, queueScheduler } from 'rxjs';
|
|
6
|
-
import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap,
|
|
5
|
+
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable, queueScheduler } from 'rxjs';
|
|
6
|
+
import { filter, map, share, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, observeOn, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @fileoverview added by tsickle
|
|
@@ -512,156 +512,6 @@ if (false) {
|
|
|
512
512
|
NgxsExecutionStrategy.prototype.leave = function (func) { };
|
|
513
513
|
}
|
|
514
514
|
|
|
515
|
-
/**
|
|
516
|
-
* @fileoverview added by tsickle
|
|
517
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
518
|
-
*/
|
|
519
|
-
/**
|
|
520
|
-
* Returns the type from an action instance/class.
|
|
521
|
-
* @ignore
|
|
522
|
-
* @param {?} action
|
|
523
|
-
* @return {?}
|
|
524
|
-
*/
|
|
525
|
-
function getActionTypeFromInstance(action) {
|
|
526
|
-
if (action.constructor && action.constructor.type) {
|
|
527
|
-
return action.constructor.type;
|
|
528
|
-
}
|
|
529
|
-
else {
|
|
530
|
-
return action.type;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Matches a action
|
|
535
|
-
* @ignore
|
|
536
|
-
* @param {?} action1
|
|
537
|
-
* @return {?}
|
|
538
|
-
*/
|
|
539
|
-
function actionMatcher(action1) {
|
|
540
|
-
/** @type {?} */
|
|
541
|
-
var type1 = getActionTypeFromInstance(action1);
|
|
542
|
-
return (/**
|
|
543
|
-
* @param {?} action2
|
|
544
|
-
* @return {?}
|
|
545
|
-
*/
|
|
546
|
-
function (action2) {
|
|
547
|
-
return type1 === getActionTypeFromInstance(action2);
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
/**
|
|
551
|
-
* Set a deeply nested value. Example:
|
|
552
|
-
*
|
|
553
|
-
* setValue({ foo: { bar: { eat: false } } },
|
|
554
|
-
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
555
|
-
*
|
|
556
|
-
* While it traverses it also creates new objects from top down.
|
|
557
|
-
*
|
|
558
|
-
* @ignore
|
|
559
|
-
* @type {?}
|
|
560
|
-
*/
|
|
561
|
-
var setValue = (/**
|
|
562
|
-
* @param {?} obj
|
|
563
|
-
* @param {?} prop
|
|
564
|
-
* @param {?} val
|
|
565
|
-
* @return {?}
|
|
566
|
-
*/
|
|
567
|
-
function (obj, prop, val) {
|
|
568
|
-
obj = __assign({}, obj);
|
|
569
|
-
/** @type {?} */
|
|
570
|
-
var split = prop.split('.');
|
|
571
|
-
/** @type {?} */
|
|
572
|
-
var lastIndex = split.length - 1;
|
|
573
|
-
split.reduce((/**
|
|
574
|
-
* @param {?} acc
|
|
575
|
-
* @param {?} part
|
|
576
|
-
* @param {?} index
|
|
577
|
-
* @return {?}
|
|
578
|
-
*/
|
|
579
|
-
function (acc, part, index) {
|
|
580
|
-
if (index === lastIndex) {
|
|
581
|
-
acc[part] = val;
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : __assign({}, acc[part]);
|
|
585
|
-
}
|
|
586
|
-
return acc && acc[part];
|
|
587
|
-
}), obj);
|
|
588
|
-
return obj;
|
|
589
|
-
});
|
|
590
|
-
/**
|
|
591
|
-
* Get a deeply nested value. Example:
|
|
592
|
-
*
|
|
593
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
594
|
-
*
|
|
595
|
-
* @ignore
|
|
596
|
-
* @type {?}
|
|
597
|
-
*/
|
|
598
|
-
var getValue = (/**
|
|
599
|
-
* @param {?} obj
|
|
600
|
-
* @param {?} prop
|
|
601
|
-
* @return {?}
|
|
602
|
-
*/
|
|
603
|
-
function (obj, prop) {
|
|
604
|
-
return prop.split('.').reduce((/**
|
|
605
|
-
* @param {?} acc
|
|
606
|
-
* @param {?} part
|
|
607
|
-
* @return {?}
|
|
608
|
-
*/
|
|
609
|
-
function (acc, part) { return acc && acc[part]; }), obj);
|
|
610
|
-
});
|
|
611
|
-
/**
|
|
612
|
-
* Simple object check.
|
|
613
|
-
*
|
|
614
|
-
* isObject({a:1}) //=> true
|
|
615
|
-
* isObject(1) //=> false
|
|
616
|
-
*
|
|
617
|
-
* @ignore
|
|
618
|
-
* @type {?}
|
|
619
|
-
*/
|
|
620
|
-
var isObject = (/**
|
|
621
|
-
* @param {?} item
|
|
622
|
-
* @return {?}
|
|
623
|
-
*/
|
|
624
|
-
function (item) {
|
|
625
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
626
|
-
});
|
|
627
|
-
/**
|
|
628
|
-
* Deep merge two objects.
|
|
629
|
-
*
|
|
630
|
-
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
631
|
-
*
|
|
632
|
-
* \@param base base object onto which `sources` will be applied
|
|
633
|
-
* @type {?}
|
|
634
|
-
*/
|
|
635
|
-
var mergeDeep = (/**
|
|
636
|
-
* @param {?} base
|
|
637
|
-
* @param {...?} sources
|
|
638
|
-
* @return {?}
|
|
639
|
-
*/
|
|
640
|
-
function (base) {
|
|
641
|
-
var sources = [];
|
|
642
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
643
|
-
sources[_i - 1] = arguments[_i];
|
|
644
|
-
}
|
|
645
|
-
var _a, _b;
|
|
646
|
-
if (!sources.length)
|
|
647
|
-
return base;
|
|
648
|
-
/** @type {?} */
|
|
649
|
-
var source = sources.shift();
|
|
650
|
-
if (isObject(base) && isObject(source)) {
|
|
651
|
-
for (var key in source) {
|
|
652
|
-
if (isObject(source[key])) {
|
|
653
|
-
if (!base[key])
|
|
654
|
-
Object.assign(base, (_a = {}, _a[key] = {}, _a));
|
|
655
|
-
mergeDeep(base[key], source[key]);
|
|
656
|
-
}
|
|
657
|
-
else {
|
|
658
|
-
Object.assign(base, (_b = {}, _b[key] = source[key], _b));
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
return mergeDeep.apply(void 0, __spread([base], sources));
|
|
663
|
-
});
|
|
664
|
-
|
|
665
515
|
/**
|
|
666
516
|
* @fileoverview added by tsickle
|
|
667
517
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -786,17 +636,6 @@ if (false) {
|
|
|
786
636
|
/** @type {?} */
|
|
787
637
|
StatesAndDefaults.prototype.states;
|
|
788
638
|
}
|
|
789
|
-
/**
|
|
790
|
-
* @record
|
|
791
|
-
* @template T
|
|
792
|
-
*/
|
|
793
|
-
function RootStateDiff() { }
|
|
794
|
-
if (false) {
|
|
795
|
-
/** @type {?} */
|
|
796
|
-
RootStateDiff.prototype.currentAppState;
|
|
797
|
-
/** @type {?} */
|
|
798
|
-
RootStateDiff.prototype.newAppState;
|
|
799
|
-
}
|
|
800
639
|
/**
|
|
801
640
|
* Ensures metadata is attached to the class and returns it.
|
|
802
641
|
*
|
|
@@ -1138,22 +977,159 @@ function topologicalSort(graph) {
|
|
|
1138
977
|
* @param {?} obj
|
|
1139
978
|
* @return {?}
|
|
1140
979
|
*/
|
|
1141
|
-
function isObject
|
|
980
|
+
function isObject(obj) {
|
|
1142
981
|
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
1143
982
|
}
|
|
983
|
+
|
|
1144
984
|
/**
|
|
1145
|
-
* @
|
|
1146
|
-
* @
|
|
1147
|
-
|
|
985
|
+
* @fileoverview added by tsickle
|
|
986
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
987
|
+
*/
|
|
988
|
+
/**
|
|
989
|
+
* Returns the type from an action instance/class.
|
|
990
|
+
* @ignore
|
|
991
|
+
* @param {?} action
|
|
1148
992
|
* @return {?}
|
|
1149
993
|
*/
|
|
1150
|
-
function
|
|
1151
|
-
|
|
1152
|
-
|
|
994
|
+
function getActionTypeFromInstance(action) {
|
|
995
|
+
if (action.constructor && action.constructor.type) {
|
|
996
|
+
return action.constructor.type;
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
return action.type;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Matches a action
|
|
1004
|
+
* @ignore
|
|
1005
|
+
* @param {?} action1
|
|
1006
|
+
* @return {?}
|
|
1007
|
+
*/
|
|
1008
|
+
function actionMatcher(action1) {
|
|
1153
1009
|
/** @type {?} */
|
|
1154
|
-
var
|
|
1155
|
-
return
|
|
1010
|
+
var type1 = getActionTypeFromInstance(action1);
|
|
1011
|
+
return (/**
|
|
1012
|
+
* @param {?} action2
|
|
1013
|
+
* @return {?}
|
|
1014
|
+
*/
|
|
1015
|
+
function (action2) {
|
|
1016
|
+
return type1 === getActionTypeFromInstance(action2);
|
|
1017
|
+
});
|
|
1156
1018
|
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Set a deeply nested value. Example:
|
|
1021
|
+
*
|
|
1022
|
+
* setValue({ foo: { bar: { eat: false } } },
|
|
1023
|
+
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
1024
|
+
*
|
|
1025
|
+
* While it traverses it also creates new objects from top down.
|
|
1026
|
+
*
|
|
1027
|
+
* @ignore
|
|
1028
|
+
* @type {?}
|
|
1029
|
+
*/
|
|
1030
|
+
var setValue = (/**
|
|
1031
|
+
* @param {?} obj
|
|
1032
|
+
* @param {?} prop
|
|
1033
|
+
* @param {?} val
|
|
1034
|
+
* @return {?}
|
|
1035
|
+
*/
|
|
1036
|
+
function (obj, prop, val) {
|
|
1037
|
+
obj = __assign({}, obj);
|
|
1038
|
+
/** @type {?} */
|
|
1039
|
+
var split = prop.split('.');
|
|
1040
|
+
/** @type {?} */
|
|
1041
|
+
var lastIndex = split.length - 1;
|
|
1042
|
+
split.reduce((/**
|
|
1043
|
+
* @param {?} acc
|
|
1044
|
+
* @param {?} part
|
|
1045
|
+
* @param {?} index
|
|
1046
|
+
* @return {?}
|
|
1047
|
+
*/
|
|
1048
|
+
function (acc, part, index) {
|
|
1049
|
+
if (index === lastIndex) {
|
|
1050
|
+
acc[part] = val;
|
|
1051
|
+
}
|
|
1052
|
+
else {
|
|
1053
|
+
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : __assign({}, acc[part]);
|
|
1054
|
+
}
|
|
1055
|
+
return acc && acc[part];
|
|
1056
|
+
}), obj);
|
|
1057
|
+
return obj;
|
|
1058
|
+
});
|
|
1059
|
+
/**
|
|
1060
|
+
* Get a deeply nested value. Example:
|
|
1061
|
+
*
|
|
1062
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
1063
|
+
*
|
|
1064
|
+
* @ignore
|
|
1065
|
+
* @type {?}
|
|
1066
|
+
*/
|
|
1067
|
+
var getValue = (/**
|
|
1068
|
+
* @param {?} obj
|
|
1069
|
+
* @param {?} prop
|
|
1070
|
+
* @return {?}
|
|
1071
|
+
*/
|
|
1072
|
+
function (obj, prop) {
|
|
1073
|
+
return prop.split('.').reduce((/**
|
|
1074
|
+
* @param {?} acc
|
|
1075
|
+
* @param {?} part
|
|
1076
|
+
* @return {?}
|
|
1077
|
+
*/
|
|
1078
|
+
function (acc, part) { return acc && acc[part]; }), obj);
|
|
1079
|
+
});
|
|
1080
|
+
/**
|
|
1081
|
+
* Simple object check.
|
|
1082
|
+
*
|
|
1083
|
+
* isObject({a:1}) //=> true
|
|
1084
|
+
* isObject(1) //=> false
|
|
1085
|
+
*
|
|
1086
|
+
* @ignore
|
|
1087
|
+
* @type {?}
|
|
1088
|
+
*/
|
|
1089
|
+
var isObject$1 = (/**
|
|
1090
|
+
* @param {?} item
|
|
1091
|
+
* @return {?}
|
|
1092
|
+
*/
|
|
1093
|
+
function (item) {
|
|
1094
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
1095
|
+
});
|
|
1096
|
+
/**
|
|
1097
|
+
* Deep merge two objects.
|
|
1098
|
+
*
|
|
1099
|
+
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
1100
|
+
*
|
|
1101
|
+
* \@param base base object onto which `sources` will be applied
|
|
1102
|
+
* @type {?}
|
|
1103
|
+
*/
|
|
1104
|
+
var mergeDeep = (/**
|
|
1105
|
+
* @param {?} base
|
|
1106
|
+
* @param {...?} sources
|
|
1107
|
+
* @return {?}
|
|
1108
|
+
*/
|
|
1109
|
+
function (base) {
|
|
1110
|
+
var sources = [];
|
|
1111
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1112
|
+
sources[_i - 1] = arguments[_i];
|
|
1113
|
+
}
|
|
1114
|
+
var _a, _b;
|
|
1115
|
+
if (!sources.length)
|
|
1116
|
+
return base;
|
|
1117
|
+
/** @type {?} */
|
|
1118
|
+
var source = sources.shift();
|
|
1119
|
+
if (isObject$1(base) && isObject$1(source)) {
|
|
1120
|
+
for (var key in source) {
|
|
1121
|
+
if (isObject$1(source[key])) {
|
|
1122
|
+
if (!base[key])
|
|
1123
|
+
Object.assign(base, (_a = {}, _a[key] = {}, _a));
|
|
1124
|
+
mergeDeep(base[key], source[key]);
|
|
1125
|
+
}
|
|
1126
|
+
else {
|
|
1127
|
+
Object.assign(base, (_b = {}, _b[key] = source[key], _b));
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return mergeDeep.apply(void 0, __spread([base], sources));
|
|
1132
|
+
});
|
|
1157
1133
|
|
|
1158
1134
|
/**
|
|
1159
1135
|
* @fileoverview added by tsickle
|
|
@@ -1586,6 +1562,15 @@ var InternalActions = /** @class */ (function (_super) {
|
|
|
1586
1562
|
function InternalActions() {
|
|
1587
1563
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
1588
1564
|
}
|
|
1565
|
+
/**
|
|
1566
|
+
* @return {?}
|
|
1567
|
+
*/
|
|
1568
|
+
InternalActions.prototype.ngOnDestroy = /**
|
|
1569
|
+
* @return {?}
|
|
1570
|
+
*/
|
|
1571
|
+
function () {
|
|
1572
|
+
this.complete();
|
|
1573
|
+
};
|
|
1589
1574
|
InternalActions.decorators = [
|
|
1590
1575
|
{ type: Injectable }
|
|
1591
1576
|
];
|
|
@@ -1601,15 +1586,21 @@ var Actions = /** @class */ (function (_super) {
|
|
|
1601
1586
|
// This has to be `Observable<ActionContext>` in the v4. Because `InternalActions`
|
|
1602
1587
|
// is a `Subject<ActionContext>`. Leave it as `any` to avoid breaking changes
|
|
1603
1588
|
function Actions(internalActions$, internalExecutionStrategy) {
|
|
1604
|
-
|
|
1589
|
+
var _this = this;
|
|
1590
|
+
/** @type {?} */
|
|
1591
|
+
var sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
|
|
1592
|
+
// The `InternalActions` subject emits outside of the Angular zone.
|
|
1593
|
+
// We have to re-enter the Angular zone for any incoming consumer.
|
|
1594
|
+
// The `share()` operator reduces the number of change detections.
|
|
1595
|
+
// This would call leave only once for any stream emission across all active subscribers.
|
|
1596
|
+
share());
|
|
1597
|
+
_this = _super.call(this, (/**
|
|
1605
1598
|
* @param {?} observer
|
|
1606
1599
|
* @return {?}
|
|
1607
1600
|
*/
|
|
1608
1601
|
function (observer) {
|
|
1609
1602
|
/** @type {?} */
|
|
1610
|
-
var childSubscription =
|
|
1611
|
-
.pipe(leaveNgxs(internalExecutionStrategy))
|
|
1612
|
-
.subscribe({
|
|
1603
|
+
var childSubscription = sharedInternalActions$.subscribe({
|
|
1613
1604
|
next: (/**
|
|
1614
1605
|
* @param {?} ctx
|
|
1615
1606
|
* @return {?}
|
|
@@ -1627,6 +1618,7 @@ var Actions = /** @class */ (function (_super) {
|
|
|
1627
1618
|
});
|
|
1628
1619
|
observer.add(childSubscription);
|
|
1629
1620
|
})) || this;
|
|
1621
|
+
return _this;
|
|
1630
1622
|
}
|
|
1631
1623
|
Actions.decorators = [
|
|
1632
1624
|
{ type: Injectable }
|
|
@@ -1693,6 +1685,126 @@ function () {
|
|
|
1693
1685
|
})]));
|
|
1694
1686
|
}); });
|
|
1695
1687
|
|
|
1688
|
+
/**
|
|
1689
|
+
* @fileoverview added by tsickle
|
|
1690
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
1691
|
+
*/
|
|
1692
|
+
/**
|
|
1693
|
+
* This operator is used for piping the observable result
|
|
1694
|
+
* from the `dispatch()`. It has a "smart" error handling
|
|
1695
|
+
* strategy that allows us to decide whether we propagate
|
|
1696
|
+
* errors to Angular's `ErrorHandler` or enable users to
|
|
1697
|
+
* handle them manually. We consider following cases:
|
|
1698
|
+
* 1) `store.dispatch()` (no subscribe) -> call `handleError()`
|
|
1699
|
+
* 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
|
|
1700
|
+
* 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
|
|
1701
|
+
* 4) `toPromise()` without `catch` -> do `handleError()`
|
|
1702
|
+
* 5) `toPromise()` with `catch` -> don't `handleError()`
|
|
1703
|
+
* @template T
|
|
1704
|
+
* @param {?} internalErrorReporter
|
|
1705
|
+
* @param {?} ngxsExecutionStrategy
|
|
1706
|
+
* @return {?}
|
|
1707
|
+
*/
|
|
1708
|
+
function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
|
|
1709
|
+
return (/**
|
|
1710
|
+
* @param {?} source
|
|
1711
|
+
* @return {?}
|
|
1712
|
+
*/
|
|
1713
|
+
function (source) {
|
|
1714
|
+
/** @type {?} */
|
|
1715
|
+
var subscribed = false;
|
|
1716
|
+
source.subscribe({
|
|
1717
|
+
error: (/**
|
|
1718
|
+
* @param {?} error
|
|
1719
|
+
* @return {?}
|
|
1720
|
+
*/
|
|
1721
|
+
function (error) {
|
|
1722
|
+
// Do not trigger change detection for a microtask. This depends on the execution
|
|
1723
|
+
// strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
|
|
1724
|
+
// leaves the Angular zone.
|
|
1725
|
+
ngxsExecutionStrategy.enter((/**
|
|
1726
|
+
* @return {?}
|
|
1727
|
+
*/
|
|
1728
|
+
function () {
|
|
1729
|
+
return Promise.resolve().then((/**
|
|
1730
|
+
* @return {?}
|
|
1731
|
+
*/
|
|
1732
|
+
function () {
|
|
1733
|
+
if (!subscribed) {
|
|
1734
|
+
ngxsExecutionStrategy.leave((/**
|
|
1735
|
+
* @return {?}
|
|
1736
|
+
*/
|
|
1737
|
+
function () {
|
|
1738
|
+
return internalErrorReporter.reportErrorSafely(error);
|
|
1739
|
+
}));
|
|
1740
|
+
}
|
|
1741
|
+
}));
|
|
1742
|
+
}));
|
|
1743
|
+
})
|
|
1744
|
+
});
|
|
1745
|
+
return new Observable((/**
|
|
1746
|
+
* @param {?} subscriber
|
|
1747
|
+
* @return {?}
|
|
1748
|
+
*/
|
|
1749
|
+
function (subscriber) {
|
|
1750
|
+
subscribed = true;
|
|
1751
|
+
return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
|
|
1752
|
+
}));
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
var InternalErrorReporter = /** @class */ (function () {
|
|
1756
|
+
function InternalErrorReporter(_injector) {
|
|
1757
|
+
this._injector = _injector;
|
|
1758
|
+
/**
|
|
1759
|
+
* Will be set lazily to be backward compatible.
|
|
1760
|
+
*/
|
|
1761
|
+
this._errorHandler = (/** @type {?} */ (null));
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* @param {?} error
|
|
1765
|
+
* @return {?}
|
|
1766
|
+
*/
|
|
1767
|
+
InternalErrorReporter.prototype.reportErrorSafely = /**
|
|
1768
|
+
* @param {?} error
|
|
1769
|
+
* @return {?}
|
|
1770
|
+
*/
|
|
1771
|
+
function (error) {
|
|
1772
|
+
if (this._errorHandler === null) {
|
|
1773
|
+
this._errorHandler = this._injector.get(ErrorHandler);
|
|
1774
|
+
}
|
|
1775
|
+
// The `try-catch` is used to avoid handling the error twice. Suppose we call
|
|
1776
|
+
// `handleError` which re-throws the error internally. The re-thrown error will
|
|
1777
|
+
// be caught by zone.js which will then get to the `zone.onError.emit()` and the
|
|
1778
|
+
// `onError` subscriber will call `handleError` again.
|
|
1779
|
+
try {
|
|
1780
|
+
this._errorHandler.handleError(error);
|
|
1781
|
+
}
|
|
1782
|
+
catch (_a) { }
|
|
1783
|
+
};
|
|
1784
|
+
InternalErrorReporter.decorators = [
|
|
1785
|
+
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
1786
|
+
];
|
|
1787
|
+
/** @nocollapse */
|
|
1788
|
+
InternalErrorReporter.ctorParameters = function () { return [
|
|
1789
|
+
{ type: Injector }
|
|
1790
|
+
]; };
|
|
1791
|
+
/** @nocollapse */ InternalErrorReporter.ngInjectableDef = defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(inject(INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
|
|
1792
|
+
return InternalErrorReporter;
|
|
1793
|
+
}());
|
|
1794
|
+
if (false) {
|
|
1795
|
+
/**
|
|
1796
|
+
* Will be set lazily to be backward compatible.
|
|
1797
|
+
* @type {?}
|
|
1798
|
+
* @private
|
|
1799
|
+
*/
|
|
1800
|
+
InternalErrorReporter.prototype._errorHandler;
|
|
1801
|
+
/**
|
|
1802
|
+
* @type {?}
|
|
1803
|
+
* @private
|
|
1804
|
+
*/
|
|
1805
|
+
InternalErrorReporter.prototype._injector;
|
|
1806
|
+
}
|
|
1807
|
+
|
|
1696
1808
|
/**
|
|
1697
1809
|
* @fileoverview added by tsickle
|
|
1698
1810
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -1825,13 +1937,13 @@ var InternalDispatchedActionResults = /** @class */ (function (_super) {
|
|
|
1825
1937
|
return InternalDispatchedActionResults;
|
|
1826
1938
|
}(Subject));
|
|
1827
1939
|
var InternalDispatcher = /** @class */ (function () {
|
|
1828
|
-
function InternalDispatcher(
|
|
1829
|
-
this._injector = _injector;
|
|
1940
|
+
function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
|
|
1830
1941
|
this._actions = _actions;
|
|
1831
1942
|
this._actionResults = _actionResults;
|
|
1832
1943
|
this._pluginManager = _pluginManager;
|
|
1833
1944
|
this._stateStream = _stateStream;
|
|
1834
1945
|
this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
|
|
1946
|
+
this._internalErrorReporter = _internalErrorReporter;
|
|
1835
1947
|
}
|
|
1836
1948
|
/**
|
|
1837
1949
|
* Dispatches event(s).
|
|
@@ -1855,26 +1967,7 @@ var InternalDispatcher = /** @class */ (function () {
|
|
|
1855
1967
|
function () {
|
|
1856
1968
|
return _this.dispatchByEvents(actionOrActions);
|
|
1857
1969
|
}));
|
|
1858
|
-
result.
|
|
1859
|
-
error: (/**
|
|
1860
|
-
* @param {?} error
|
|
1861
|
-
* @return {?}
|
|
1862
|
-
*/
|
|
1863
|
-
function (error) {
|
|
1864
|
-
return _this._ngxsExecutionStrategy.leave((/**
|
|
1865
|
-
* @return {?}
|
|
1866
|
-
*/
|
|
1867
|
-
function () {
|
|
1868
|
-
try {
|
|
1869
|
-
// Retrieve lazily to avoid cyclic dependency exception
|
|
1870
|
-
_this._errorHandler = _this._errorHandler || _this._injector.get(ErrorHandler);
|
|
1871
|
-
_this._errorHandler.handleError(error);
|
|
1872
|
-
}
|
|
1873
|
-
catch (_a) { }
|
|
1874
|
-
}));
|
|
1875
|
-
})
|
|
1876
|
-
});
|
|
1877
|
-
return result.pipe(leaveNgxs(this._ngxsExecutionStrategy));
|
|
1970
|
+
return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
|
|
1878
1971
|
};
|
|
1879
1972
|
/**
|
|
1880
1973
|
* @private
|
|
@@ -1999,26 +2092,16 @@ var InternalDispatcher = /** @class */ (function () {
|
|
|
1999
2092
|
];
|
|
2000
2093
|
/** @nocollapse */
|
|
2001
2094
|
InternalDispatcher.ctorParameters = function () { return [
|
|
2002
|
-
{ type: Injector },
|
|
2003
2095
|
{ type: InternalActions },
|
|
2004
2096
|
{ type: InternalDispatchedActionResults },
|
|
2005
2097
|
{ type: PluginManager },
|
|
2006
2098
|
{ type: StateStream },
|
|
2007
|
-
{ type: InternalNgxsExecutionStrategy }
|
|
2099
|
+
{ type: InternalNgxsExecutionStrategy },
|
|
2100
|
+
{ type: InternalErrorReporter }
|
|
2008
2101
|
]; };
|
|
2009
2102
|
return InternalDispatcher;
|
|
2010
2103
|
}());
|
|
2011
2104
|
if (false) {
|
|
2012
|
-
/**
|
|
2013
|
-
* @type {?}
|
|
2014
|
-
* @private
|
|
2015
|
-
*/
|
|
2016
|
-
InternalDispatcher.prototype._errorHandler;
|
|
2017
|
-
/**
|
|
2018
|
-
* @type {?}
|
|
2019
|
-
* @private
|
|
2020
|
-
*/
|
|
2021
|
-
InternalDispatcher.prototype._injector;
|
|
2022
2105
|
/**
|
|
2023
2106
|
* @type {?}
|
|
2024
2107
|
* @private
|
|
@@ -2044,6 +2127,11 @@ if (false) {
|
|
|
2044
2127
|
* @private
|
|
2045
2128
|
*/
|
|
2046
2129
|
InternalDispatcher.prototype._ngxsExecutionStrategy;
|
|
2130
|
+
/**
|
|
2131
|
+
* @type {?}
|
|
2132
|
+
* @private
|
|
2133
|
+
*/
|
|
2134
|
+
InternalDispatcher.prototype._internalErrorReporter;
|
|
2047
2135
|
}
|
|
2048
2136
|
|
|
2049
2137
|
/**
|
|
@@ -2285,16 +2373,6 @@ var StateContextFactory = /** @class */ (function () {
|
|
|
2285
2373
|
function setStateValue(currentAppState, newValue) {
|
|
2286
2374
|
/** @type {?} */
|
|
2287
2375
|
var newAppState = setValue(currentAppState, mappedStore.path, newValue);
|
|
2288
|
-
/** @type {?} */
|
|
2289
|
-
var instance = mappedStore.instance;
|
|
2290
|
-
if (instance.ngxsOnChanges) {
|
|
2291
|
-
/** @type {?} */
|
|
2292
|
-
var change = getStateDiffChanges(mappedStore, {
|
|
2293
|
-
currentAppState: currentAppState,
|
|
2294
|
-
newAppState: newAppState
|
|
2295
|
-
});
|
|
2296
|
-
instance.ngxsOnChanges(change);
|
|
2297
|
-
}
|
|
2298
2376
|
root.setState(newAppState);
|
|
2299
2377
|
return newAppState;
|
|
2300
2378
|
// In doing this refactoring I noticed that there is a 'bug' where the
|
|
@@ -2608,7 +2686,7 @@ var StateFactory = /** @class */ (function () {
|
|
|
2608
2686
|
if (Array.isArray(defaults)) {
|
|
2609
2687
|
value = defaults.slice();
|
|
2610
2688
|
}
|
|
2611
|
-
else if (isObject
|
|
2689
|
+
else if (isObject(defaults)) {
|
|
2612
2690
|
value = __assign({}, defaults);
|
|
2613
2691
|
}
|
|
2614
2692
|
else if (defaults === undefined) {
|
|
@@ -2823,7 +2901,7 @@ var StateFactory = /** @class */ (function () {
|
|
|
2823
2901
|
if (result instanceof Promise) {
|
|
2824
2902
|
result = from(result);
|
|
2825
2903
|
}
|
|
2826
|
-
if (result
|
|
2904
|
+
if (isObservable(result)) {
|
|
2827
2905
|
// If this observable has been completed w/o emitting
|
|
2828
2906
|
// any value then we wouldn't want to complete the whole chain
|
|
2829
2907
|
// of actions. Since if any observable completes then
|
|
@@ -2840,7 +2918,7 @@ var StateFactory = /** @class */ (function () {
|
|
|
2840
2918
|
if (value instanceof Promise) {
|
|
2841
2919
|
return from(value);
|
|
2842
2920
|
}
|
|
2843
|
-
if (value
|
|
2921
|
+
if (isObservable(value)) {
|
|
2844
2922
|
return value;
|
|
2845
2923
|
}
|
|
2846
2924
|
return of(value);
|
|
@@ -2933,289 +3011,120 @@ var StateFactory = /** @class */ (function () {
|
|
|
2933
3011
|
*/
|
|
2934
3012
|
StateFactory.prototype.addRuntimeInfoToMeta = /**
|
|
2935
3013
|
* @private
|
|
2936
|
-
* @param {?} meta
|
|
2937
|
-
* @param {?} path
|
|
2938
|
-
* @return {?}
|
|
2939
|
-
*/
|
|
2940
|
-
function (meta, path) {
|
|
2941
|
-
this.statePaths[(/** @type {?} */ (meta.name))] = path;
|
|
2942
|
-
// TODO: v4 - we plan to get rid of the path property because it is non-deterministic
|
|
2943
|
-
// we can do this when we get rid of the incorrectly exposed getStoreMetadata
|
|
2944
|
-
// We will need to come up with an alternative in v4 because this is used by many plugins
|
|
2945
|
-
meta.path = path;
|
|
2946
|
-
};
|
|
2947
|
-
/**
|
|
2948
|
-
* @description
|
|
2949
|
-
* the method checks if the state has already been added to the tree
|
|
2950
|
-
* and completed the life cycle
|
|
2951
|
-
* @param name
|
|
2952
|
-
* @param path
|
|
2953
|
-
*/
|
|
2954
|
-
/**
|
|
2955
|
-
* \@description
|
|
2956
|
-
* the method checks if the state has already been added to the tree
|
|
2957
|
-
* and completed the life cycle
|
|
2958
|
-
* @private
|
|
2959
|
-
* @param {?} name
|
|
2960
|
-
* @param {?} path
|
|
2961
|
-
* @return {?}
|
|
2962
|
-
*/
|
|
2963
|
-
StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
|
|
2964
|
-
* \@description
|
|
2965
|
-
* the method checks if the state has already been added to the tree
|
|
2966
|
-
* and completed the life cycle
|
|
2967
|
-
* @private
|
|
2968
|
-
* @param {?} name
|
|
2969
|
-
* @param {?} path
|
|
2970
|
-
* @return {?}
|
|
2971
|
-
*/
|
|
2972
|
-
function (name, path) {
|
|
2973
|
-
/** @type {?} */
|
|
2974
|
-
var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
|
|
2975
|
-
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
2976
|
-
};
|
|
2977
|
-
StateFactory.decorators = [
|
|
2978
|
-
{ type: Injectable }
|
|
2979
|
-
];
|
|
2980
|
-
/** @nocollapse */
|
|
2981
|
-
StateFactory.ctorParameters = function () { return [
|
|
2982
|
-
{ type: Injector },
|
|
2983
|
-
{ type: NgxsConfig },
|
|
2984
|
-
{ type: StateFactory, decorators: [{ type: Optional }, { type: SkipSelf }] },
|
|
2985
|
-
{ type: InternalActions },
|
|
2986
|
-
{ type: InternalDispatchedActionResults },
|
|
2987
|
-
{ type: StateContextFactory },
|
|
2988
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
|
|
2989
|
-
]; };
|
|
2990
|
-
return StateFactory;
|
|
2991
|
-
}());
|
|
2992
|
-
if (false) {
|
|
2993
|
-
/**
|
|
2994
|
-
* @type {?}
|
|
2995
|
-
* @private
|
|
2996
|
-
*/
|
|
2997
|
-
StateFactory.prototype._actionsSubscription;
|
|
2998
|
-
/**
|
|
2999
|
-
* @type {?}
|
|
3000
|
-
* @private
|
|
3001
|
-
*/
|
|
3002
|
-
StateFactory.prototype._states;
|
|
3003
|
-
/**
|
|
3004
|
-
* @type {?}
|
|
3005
|
-
* @private
|
|
3006
|
-
*/
|
|
3007
|
-
StateFactory.prototype._statesByName;
|
|
3008
|
-
/**
|
|
3009
|
-
* @type {?}
|
|
3010
|
-
* @private
|
|
3011
|
-
*/
|
|
3012
|
-
StateFactory.prototype._statePaths;
|
|
3013
|
-
/** @type {?} */
|
|
3014
|
-
StateFactory.prototype.getRuntimeSelectorContext;
|
|
3015
|
-
/**
|
|
3016
|
-
* @type {?}
|
|
3017
|
-
* @private
|
|
3018
|
-
*/
|
|
3019
|
-
StateFactory.prototype._injector;
|
|
3020
|
-
/**
|
|
3021
|
-
* @type {?}
|
|
3022
|
-
* @private
|
|
3023
|
-
*/
|
|
3024
|
-
StateFactory.prototype._config;
|
|
3025
|
-
/**
|
|
3026
|
-
* @type {?}
|
|
3027
|
-
* @private
|
|
3028
|
-
*/
|
|
3029
|
-
StateFactory.prototype._parentFactory;
|
|
3030
|
-
/**
|
|
3031
|
-
* @type {?}
|
|
3032
|
-
* @private
|
|
3033
|
-
*/
|
|
3034
|
-
StateFactory.prototype._actions;
|
|
3035
|
-
/**
|
|
3036
|
-
* @type {?}
|
|
3037
|
-
* @private
|
|
3038
|
-
*/
|
|
3039
|
-
StateFactory.prototype._actionResults;
|
|
3040
|
-
/**
|
|
3041
|
-
* @type {?}
|
|
3042
|
-
* @private
|
|
3043
|
-
*/
|
|
3044
|
-
StateFactory.prototype._stateContextFactory;
|
|
3045
|
-
/**
|
|
3046
|
-
* @type {?}
|
|
3047
|
-
* @private
|
|
3048
|
-
*/
|
|
3049
|
-
StateFactory.prototype._initialState;
|
|
3050
|
-
}
|
|
3051
|
-
|
|
3052
|
-
/**
|
|
3053
|
-
* @fileoverview added by tsickle
|
|
3054
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3055
|
-
*/
|
|
3056
|
-
var LifecycleStateManager = /** @class */ (function () {
|
|
3057
|
-
function LifecycleStateManager(internalStateOperations, stateContextFactory, bootstrapper) {
|
|
3058
|
-
this.internalStateOperations = internalStateOperations;
|
|
3059
|
-
this.stateContextFactory = stateContextFactory;
|
|
3060
|
-
this.bootstrapper = bootstrapper;
|
|
3061
|
-
}
|
|
3062
|
-
/**
|
|
3063
|
-
* @template T
|
|
3064
|
-
* @param {?} action
|
|
3065
|
-
* @param {?} results
|
|
3066
|
-
* @return {?}
|
|
3067
|
-
*/
|
|
3068
|
-
LifecycleStateManager.prototype.ngxsBootstrap = /**
|
|
3069
|
-
* @template T
|
|
3070
|
-
* @param {?} action
|
|
3071
|
-
* @param {?} results
|
|
3072
|
-
* @return {?}
|
|
3073
|
-
*/
|
|
3074
|
-
function (action, results) {
|
|
3075
|
-
var _this = this;
|
|
3076
|
-
this.internalStateOperations
|
|
3077
|
-
.getRootStateOperations()
|
|
3078
|
-
.dispatch(action)
|
|
3079
|
-
.pipe(filter((/**
|
|
3080
|
-
* @return {?}
|
|
3081
|
-
*/
|
|
3082
|
-
function () { return !!results; })), tap((/**
|
|
3083
|
-
* @return {?}
|
|
3084
|
-
*/
|
|
3085
|
-
function () { return _this.invokeInit((/** @type {?} */ (results)).states); })), mergeMap((/**
|
|
3086
|
-
* @return {?}
|
|
3087
|
-
*/
|
|
3088
|
-
function () { return _this.bootstrapper.appBootstrapped$; })), filter((/**
|
|
3089
|
-
* @param {?} appBootstrapped
|
|
3090
|
-
* @return {?}
|
|
3091
|
-
*/
|
|
3092
|
-
function (appBootstrapped) { return !!appBootstrapped; })))
|
|
3093
|
-
.subscribe((/**
|
|
3094
|
-
* @return {?}
|
|
3095
|
-
*/
|
|
3096
|
-
function () { return _this.invokeBootstrap((/** @type {?} */ (results)).states); }));
|
|
3097
|
-
};
|
|
3098
|
-
/**
|
|
3099
|
-
* Invoke the init function on the states.
|
|
3100
|
-
*/
|
|
3101
|
-
/**
|
|
3102
|
-
* Invoke the init function on the states.
|
|
3103
|
-
* @param {?} mappedStores
|
|
3104
|
-
* @return {?}
|
|
3105
|
-
*/
|
|
3106
|
-
LifecycleStateManager.prototype.invokeInit = /**
|
|
3107
|
-
* Invoke the init function on the states.
|
|
3108
|
-
* @param {?} mappedStores
|
|
3109
|
-
* @return {?}
|
|
3110
|
-
*/
|
|
3111
|
-
function (mappedStores) {
|
|
3112
|
-
var e_1, _a;
|
|
3113
|
-
try {
|
|
3114
|
-
for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
|
|
3115
|
-
var mappedStore = mappedStores_1_1.value;
|
|
3116
|
-
/** @type {?} */
|
|
3117
|
-
var instance = mappedStore.instance;
|
|
3118
|
-
if (instance.ngxsOnChanges) {
|
|
3119
|
-
/** @type {?} */
|
|
3120
|
-
var currentAppState = {};
|
|
3121
|
-
/** @type {?} */
|
|
3122
|
-
var newAppState = this.internalStateOperations
|
|
3123
|
-
.getRootStateOperations()
|
|
3124
|
-
.getState();
|
|
3125
|
-
/** @type {?} */
|
|
3126
|
-
var firstDiffChange = getStateDiffChanges(mappedStore, {
|
|
3127
|
-
currentAppState: currentAppState,
|
|
3128
|
-
newAppState: newAppState
|
|
3129
|
-
});
|
|
3130
|
-
instance.ngxsOnChanges(firstDiffChange);
|
|
3131
|
-
}
|
|
3132
|
-
if (instance.ngxsOnInit) {
|
|
3133
|
-
instance.ngxsOnInit(this.getStateContext(mappedStore));
|
|
3134
|
-
}
|
|
3135
|
-
mappedStore.isInitialised = true;
|
|
3136
|
-
}
|
|
3137
|
-
}
|
|
3138
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3139
|
-
finally {
|
|
3140
|
-
try {
|
|
3141
|
-
if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
|
|
3142
|
-
}
|
|
3143
|
-
finally { if (e_1) throw e_1.error; }
|
|
3144
|
-
}
|
|
3145
|
-
};
|
|
3146
|
-
/**
|
|
3147
|
-
* Invoke the bootstrap function on the states.
|
|
3148
|
-
*/
|
|
3149
|
-
/**
|
|
3150
|
-
* Invoke the bootstrap function on the states.
|
|
3151
|
-
* @param {?} mappedStores
|
|
3152
|
-
* @return {?}
|
|
3153
|
-
*/
|
|
3154
|
-
LifecycleStateManager.prototype.invokeBootstrap = /**
|
|
3155
|
-
* Invoke the bootstrap function on the states.
|
|
3156
|
-
* @param {?} mappedStores
|
|
3157
|
-
* @return {?}
|
|
3158
|
-
*/
|
|
3159
|
-
function (mappedStores) {
|
|
3160
|
-
var e_2, _a;
|
|
3161
|
-
try {
|
|
3162
|
-
for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
|
|
3163
|
-
var mappedStore = mappedStores_2_1.value;
|
|
3164
|
-
/** @type {?} */
|
|
3165
|
-
var instance = mappedStore.instance;
|
|
3166
|
-
if (instance.ngxsAfterBootstrap) {
|
|
3167
|
-
instance.ngxsAfterBootstrap(this.getStateContext(mappedStore));
|
|
3168
|
-
}
|
|
3169
|
-
}
|
|
3170
|
-
}
|
|
3171
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3172
|
-
finally {
|
|
3173
|
-
try {
|
|
3174
|
-
if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
|
|
3175
|
-
}
|
|
3176
|
-
finally { if (e_2) throw e_2.error; }
|
|
3177
|
-
}
|
|
3014
|
+
* @param {?} meta
|
|
3015
|
+
* @param {?} path
|
|
3016
|
+
* @return {?}
|
|
3017
|
+
*/
|
|
3018
|
+
function (meta, path) {
|
|
3019
|
+
this.statePaths[(/** @type {?} */ (meta.name))] = path;
|
|
3020
|
+
// TODO: v4 - we plan to get rid of the path property because it is non-deterministic
|
|
3021
|
+
// we can do this when we get rid of the incorrectly exposed getStoreMetadata
|
|
3022
|
+
// We will need to come up with an alternative in v4 because this is used by many plugins
|
|
3023
|
+
meta.path = path;
|
|
3178
3024
|
};
|
|
3179
3025
|
/**
|
|
3026
|
+
* @description
|
|
3027
|
+
* the method checks if the state has already been added to the tree
|
|
3028
|
+
* and completed the life cycle
|
|
3029
|
+
* @param name
|
|
3030
|
+
* @param path
|
|
3031
|
+
*/
|
|
3032
|
+
/**
|
|
3033
|
+
* \@description
|
|
3034
|
+
* the method checks if the state has already been added to the tree
|
|
3035
|
+
* and completed the life cycle
|
|
3180
3036
|
* @private
|
|
3181
|
-
* @param {?}
|
|
3037
|
+
* @param {?} name
|
|
3038
|
+
* @param {?} path
|
|
3182
3039
|
* @return {?}
|
|
3183
3040
|
*/
|
|
3184
|
-
|
|
3041
|
+
StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
|
|
3042
|
+
* \@description
|
|
3043
|
+
* the method checks if the state has already been added to the tree
|
|
3044
|
+
* and completed the life cycle
|
|
3185
3045
|
* @private
|
|
3186
|
-
* @param {?}
|
|
3046
|
+
* @param {?} name
|
|
3047
|
+
* @param {?} path
|
|
3187
3048
|
* @return {?}
|
|
3188
3049
|
*/
|
|
3189
|
-
function (
|
|
3190
|
-
|
|
3050
|
+
function (name, path) {
|
|
3051
|
+
/** @type {?} */
|
|
3052
|
+
var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
|
|
3053
|
+
return this.statesByName[name] && valueIsBootstrappedInInitialState;
|
|
3191
3054
|
};
|
|
3192
|
-
|
|
3055
|
+
StateFactory.decorators = [
|
|
3193
3056
|
{ type: Injectable }
|
|
3194
3057
|
];
|
|
3195
3058
|
/** @nocollapse */
|
|
3196
|
-
|
|
3197
|
-
{ type:
|
|
3059
|
+
StateFactory.ctorParameters = function () { return [
|
|
3060
|
+
{ type: Injector },
|
|
3061
|
+
{ type: NgxsConfig },
|
|
3062
|
+
{ type: StateFactory, decorators: [{ type: Optional }, { type: SkipSelf }] },
|
|
3063
|
+
{ type: InternalActions },
|
|
3064
|
+
{ type: InternalDispatchedActionResults },
|
|
3198
3065
|
{ type: StateContextFactory },
|
|
3199
|
-
{ type:
|
|
3066
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
|
|
3200
3067
|
]; };
|
|
3201
|
-
return
|
|
3068
|
+
return StateFactory;
|
|
3202
3069
|
}());
|
|
3203
3070
|
if (false) {
|
|
3204
3071
|
/**
|
|
3205
3072
|
* @type {?}
|
|
3206
3073
|
* @private
|
|
3207
3074
|
*/
|
|
3208
|
-
|
|
3075
|
+
StateFactory.prototype._actionsSubscription;
|
|
3076
|
+
/**
|
|
3077
|
+
* @type {?}
|
|
3078
|
+
* @private
|
|
3079
|
+
*/
|
|
3080
|
+
StateFactory.prototype._states;
|
|
3081
|
+
/**
|
|
3082
|
+
* @type {?}
|
|
3083
|
+
* @private
|
|
3084
|
+
*/
|
|
3085
|
+
StateFactory.prototype._statesByName;
|
|
3086
|
+
/**
|
|
3087
|
+
* @type {?}
|
|
3088
|
+
* @private
|
|
3089
|
+
*/
|
|
3090
|
+
StateFactory.prototype._statePaths;
|
|
3091
|
+
/** @type {?} */
|
|
3092
|
+
StateFactory.prototype.getRuntimeSelectorContext;
|
|
3093
|
+
/**
|
|
3094
|
+
* @type {?}
|
|
3095
|
+
* @private
|
|
3096
|
+
*/
|
|
3097
|
+
StateFactory.prototype._injector;
|
|
3098
|
+
/**
|
|
3099
|
+
* @type {?}
|
|
3100
|
+
* @private
|
|
3101
|
+
*/
|
|
3102
|
+
StateFactory.prototype._config;
|
|
3103
|
+
/**
|
|
3104
|
+
* @type {?}
|
|
3105
|
+
* @private
|
|
3106
|
+
*/
|
|
3107
|
+
StateFactory.prototype._parentFactory;
|
|
3108
|
+
/**
|
|
3109
|
+
* @type {?}
|
|
3110
|
+
* @private
|
|
3111
|
+
*/
|
|
3112
|
+
StateFactory.prototype._actions;
|
|
3113
|
+
/**
|
|
3114
|
+
* @type {?}
|
|
3115
|
+
* @private
|
|
3116
|
+
*/
|
|
3117
|
+
StateFactory.prototype._actionResults;
|
|
3209
3118
|
/**
|
|
3210
3119
|
* @type {?}
|
|
3211
3120
|
* @private
|
|
3212
3121
|
*/
|
|
3213
|
-
|
|
3122
|
+
StateFactory.prototype._stateContextFactory;
|
|
3214
3123
|
/**
|
|
3215
3124
|
* @type {?}
|
|
3216
3125
|
* @private
|
|
3217
3126
|
*/
|
|
3218
|
-
|
|
3127
|
+
StateFactory.prototype._initialState;
|
|
3219
3128
|
}
|
|
3220
3129
|
|
|
3221
3130
|
/**
|
|
@@ -3672,6 +3581,218 @@ if (false) {
|
|
|
3672
3581
|
Store.prototype._stateFactory;
|
|
3673
3582
|
}
|
|
3674
3583
|
|
|
3584
|
+
/**
|
|
3585
|
+
* @fileoverview added by tsickle
|
|
3586
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3587
|
+
*/
|
|
3588
|
+
var LifecycleStateManager = /** @class */ (function () {
|
|
3589
|
+
function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3590
|
+
this._store = _store;
|
|
3591
|
+
this._internalErrorReporter = _internalErrorReporter;
|
|
3592
|
+
this._internalStateOperations = _internalStateOperations;
|
|
3593
|
+
this._stateContextFactory = _stateContextFactory;
|
|
3594
|
+
this._bootstrapper = _bootstrapper;
|
|
3595
|
+
this._destroy$ = new Subject();
|
|
3596
|
+
}
|
|
3597
|
+
/**
|
|
3598
|
+
* @return {?}
|
|
3599
|
+
*/
|
|
3600
|
+
LifecycleStateManager.prototype.ngOnDestroy = /**
|
|
3601
|
+
* @return {?}
|
|
3602
|
+
*/
|
|
3603
|
+
function () {
|
|
3604
|
+
this._destroy$.next();
|
|
3605
|
+
};
|
|
3606
|
+
/**
|
|
3607
|
+
* @template T
|
|
3608
|
+
* @param {?} action
|
|
3609
|
+
* @param {?} results
|
|
3610
|
+
* @return {?}
|
|
3611
|
+
*/
|
|
3612
|
+
LifecycleStateManager.prototype.ngxsBootstrap = /**
|
|
3613
|
+
* @template T
|
|
3614
|
+
* @param {?} action
|
|
3615
|
+
* @param {?} results
|
|
3616
|
+
* @return {?}
|
|
3617
|
+
*/
|
|
3618
|
+
function (action, results) {
|
|
3619
|
+
var _this = this;
|
|
3620
|
+
this._internalStateOperations
|
|
3621
|
+
.getRootStateOperations()
|
|
3622
|
+
.dispatch(action)
|
|
3623
|
+
.pipe(filter((/**
|
|
3624
|
+
* @return {?}
|
|
3625
|
+
*/
|
|
3626
|
+
function () { return !!results; })), tap((/**
|
|
3627
|
+
* @return {?}
|
|
3628
|
+
*/
|
|
3629
|
+
function () { return _this._invokeInitOnStates((/** @type {?} */ (results)).states); })), mergeMap((/**
|
|
3630
|
+
* @return {?}
|
|
3631
|
+
*/
|
|
3632
|
+
function () { return _this._bootstrapper.appBootstrapped$; })), filter((/**
|
|
3633
|
+
* @param {?} appBootstrapped
|
|
3634
|
+
* @return {?}
|
|
3635
|
+
*/
|
|
3636
|
+
function (appBootstrapped) { return !!appBootstrapped; })), catchError((/**
|
|
3637
|
+
* @param {?} error
|
|
3638
|
+
* @return {?}
|
|
3639
|
+
*/
|
|
3640
|
+
function (error) {
|
|
3641
|
+
// The `SafeSubscriber` (which is used by most RxJS operators) re-throws
|
|
3642
|
+
// errors asynchronously (`setTimeout(() => { throw error })`). This might
|
|
3643
|
+
// break existing user's code or unit tests. We catch the error manually to
|
|
3644
|
+
// be backward compatible with the old behavior.
|
|
3645
|
+
_this._internalErrorReporter.reportErrorSafely(error);
|
|
3646
|
+
return EMPTY;
|
|
3647
|
+
})), takeUntil(this._destroy$))
|
|
3648
|
+
.subscribe((/**
|
|
3649
|
+
* @return {?}
|
|
3650
|
+
*/
|
|
3651
|
+
function () { return _this._invokeBootstrapOnStates((/** @type {?} */ (results)).states); }));
|
|
3652
|
+
};
|
|
3653
|
+
/**
|
|
3654
|
+
* @private
|
|
3655
|
+
* @param {?} mappedStores
|
|
3656
|
+
* @return {?}
|
|
3657
|
+
*/
|
|
3658
|
+
LifecycleStateManager.prototype._invokeInitOnStates = /**
|
|
3659
|
+
* @private
|
|
3660
|
+
* @param {?} mappedStores
|
|
3661
|
+
* @return {?}
|
|
3662
|
+
*/
|
|
3663
|
+
function (mappedStores) {
|
|
3664
|
+
var e_1, _a;
|
|
3665
|
+
var _loop_1 = function (mappedStore) {
|
|
3666
|
+
/** @type {?} */
|
|
3667
|
+
var instance = mappedStore.instance;
|
|
3668
|
+
if (instance.ngxsOnChanges) {
|
|
3669
|
+
this_1._store
|
|
3670
|
+
.select((/**
|
|
3671
|
+
* @param {?} state
|
|
3672
|
+
* @return {?}
|
|
3673
|
+
*/
|
|
3674
|
+
function (state) { return getValue(state, mappedStore.path); }))
|
|
3675
|
+
.pipe(startWith(undefined), pairwise(), takeUntil(this_1._destroy$))
|
|
3676
|
+
.subscribe((/**
|
|
3677
|
+
* @param {?} __0
|
|
3678
|
+
* @return {?}
|
|
3679
|
+
*/
|
|
3680
|
+
function (_a) {
|
|
3681
|
+
var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
|
|
3682
|
+
/** @type {?} */
|
|
3683
|
+
var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
|
|
3684
|
+
(/** @type {?} */ (instance.ngxsOnChanges))(change);
|
|
3685
|
+
}));
|
|
3686
|
+
}
|
|
3687
|
+
if (instance.ngxsOnInit) {
|
|
3688
|
+
instance.ngxsOnInit(this_1._getStateContext(mappedStore));
|
|
3689
|
+
}
|
|
3690
|
+
mappedStore.isInitialised = true;
|
|
3691
|
+
};
|
|
3692
|
+
var this_1 = this;
|
|
3693
|
+
try {
|
|
3694
|
+
for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
|
|
3695
|
+
var mappedStore = mappedStores_1_1.value;
|
|
3696
|
+
_loop_1(mappedStore);
|
|
3697
|
+
}
|
|
3698
|
+
}
|
|
3699
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
3700
|
+
finally {
|
|
3701
|
+
try {
|
|
3702
|
+
if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
|
|
3703
|
+
}
|
|
3704
|
+
finally { if (e_1) throw e_1.error; }
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3707
|
+
/**
|
|
3708
|
+
* @private
|
|
3709
|
+
* @param {?} mappedStores
|
|
3710
|
+
* @return {?}
|
|
3711
|
+
*/
|
|
3712
|
+
LifecycleStateManager.prototype._invokeBootstrapOnStates = /**
|
|
3713
|
+
* @private
|
|
3714
|
+
* @param {?} mappedStores
|
|
3715
|
+
* @return {?}
|
|
3716
|
+
*/
|
|
3717
|
+
function (mappedStores) {
|
|
3718
|
+
var e_2, _a;
|
|
3719
|
+
try {
|
|
3720
|
+
for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
|
|
3721
|
+
var mappedStore = mappedStores_2_1.value;
|
|
3722
|
+
/** @type {?} */
|
|
3723
|
+
var instance = mappedStore.instance;
|
|
3724
|
+
if (instance.ngxsAfterBootstrap) {
|
|
3725
|
+
instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
3730
|
+
finally {
|
|
3731
|
+
try {
|
|
3732
|
+
if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
|
|
3733
|
+
}
|
|
3734
|
+
finally { if (e_2) throw e_2.error; }
|
|
3735
|
+
}
|
|
3736
|
+
};
|
|
3737
|
+
/**
|
|
3738
|
+
* @private
|
|
3739
|
+
* @param {?} mappedStore
|
|
3740
|
+
* @return {?}
|
|
3741
|
+
*/
|
|
3742
|
+
LifecycleStateManager.prototype._getStateContext = /**
|
|
3743
|
+
* @private
|
|
3744
|
+
* @param {?} mappedStore
|
|
3745
|
+
* @return {?}
|
|
3746
|
+
*/
|
|
3747
|
+
function (mappedStore) {
|
|
3748
|
+
return this._stateContextFactory.createStateContext(mappedStore);
|
|
3749
|
+
};
|
|
3750
|
+
LifecycleStateManager.decorators = [
|
|
3751
|
+
{ type: Injectable }
|
|
3752
|
+
];
|
|
3753
|
+
/** @nocollapse */
|
|
3754
|
+
LifecycleStateManager.ctorParameters = function () { return [
|
|
3755
|
+
{ type: Store },
|
|
3756
|
+
{ type: InternalErrorReporter },
|
|
3757
|
+
{ type: InternalStateOperations },
|
|
3758
|
+
{ type: StateContextFactory },
|
|
3759
|
+
{ type: NgxsBootstrapper }
|
|
3760
|
+
]; };
|
|
3761
|
+
return LifecycleStateManager;
|
|
3762
|
+
}());
|
|
3763
|
+
if (false) {
|
|
3764
|
+
/**
|
|
3765
|
+
* @type {?}
|
|
3766
|
+
* @private
|
|
3767
|
+
*/
|
|
3768
|
+
LifecycleStateManager.prototype._destroy$;
|
|
3769
|
+
/**
|
|
3770
|
+
* @type {?}
|
|
3771
|
+
* @private
|
|
3772
|
+
*/
|
|
3773
|
+
LifecycleStateManager.prototype._store;
|
|
3774
|
+
/**
|
|
3775
|
+
* @type {?}
|
|
3776
|
+
* @private
|
|
3777
|
+
*/
|
|
3778
|
+
LifecycleStateManager.prototype._internalErrorReporter;
|
|
3779
|
+
/**
|
|
3780
|
+
* @type {?}
|
|
3781
|
+
* @private
|
|
3782
|
+
*/
|
|
3783
|
+
LifecycleStateManager.prototype._internalStateOperations;
|
|
3784
|
+
/**
|
|
3785
|
+
* @type {?}
|
|
3786
|
+
* @private
|
|
3787
|
+
*/
|
|
3788
|
+
LifecycleStateManager.prototype._stateContextFactory;
|
|
3789
|
+
/**
|
|
3790
|
+
* @type {?}
|
|
3791
|
+
* @private
|
|
3792
|
+
*/
|
|
3793
|
+
LifecycleStateManager.prototype._bootstrapper;
|
|
3794
|
+
}
|
|
3795
|
+
|
|
3675
3796
|
/**
|
|
3676
3797
|
* @fileoverview added by tsickle
|
|
3677
3798
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -4494,5 +4615,5 @@ if (false) {
|
|
|
4494
4615
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
4495
4616
|
*/
|
|
4496
4617
|
|
|
4497
|
-
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq,
|
|
4618
|
+
export { Action, Actions, InitState, NGXS_PLUGINS, NgxsModule, NgxsSimpleChange, NoopNgxsExecutionStrategy, Select, Selector, SelectorOptions, State, StateStream, StateToken, Store, UpdateState, actionMatcher, createSelector, ensureSelectorMetadata$1 as ensureSelectorMetadata, ensureStoreMetadata$1 as ensureStoreMetadata, getActionTypeFromInstance, getSelectorMetadata$1 as getSelectorMetadata, getStoreMetadata$1 as getStoreMetadata, getValue, ofAction, ofActionCanceled, ofActionCompleted, ofActionDispatched, ofActionErrored, ofActionSuccessful, setValue, OrderedSubject as ɵa, InternalActions as ɵb, ROOT_STATE_TOKEN as ɵc, FEATURE_STATE_TOKEN as ɵd, SELECTOR_META_KEY as ɵe, NgxsConfig as ɵf, mergeDeep as ɵg, USER_PROVIDED_NGXS_EXECUTION_STRATEGY as ɵh, NGXS_EXECUTION_STRATEGY as ɵi, NgxsRootModule as ɵj, StateFactory as ɵk, InternalDispatchedActionResults as ɵl, InternalDispatcher as ɵm, StateContextFactory as ɵn, InternalStateOperations as ɵo, PluginManager as ɵp, InternalNgxsExecutionStrategy as ɵq, InternalErrorReporter as ɵr, SelectFactory as ɵs, ensureStoreMetadata as ɵu, getStoreMetadata as ɵv, ensureSelectorMetadata as ɵw, getSelectorMetadata as ɵx, LifecycleStateManager as ɵy, NgxsFeatureModule as ɵz };
|
|
4498
4619
|
//# sourceMappingURL=ngxs-store.js.map
|