@ngxs/store 3.7.5 → 3.7.6-dev.master-a585f14

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.
Files changed (71) hide show
  1. package/bundles/ngxs-store-operators.umd.js +13 -12
  2. package/bundles/ngxs-store-operators.umd.js.map +1 -1
  3. package/bundles/ngxs-store-operators.umd.min.js +1 -1
  4. package/bundles/ngxs-store-operators.umd.min.js.map +1 -1
  5. package/bundles/ngxs-store.umd.js +611 -485
  6. package/bundles/ngxs-store.umd.js.map +1 -1
  7. package/bundles/ngxs-store.umd.min.js +1 -1
  8. package/bundles/ngxs-store.umd.min.js.map +1 -1
  9. package/esm2015/ngxs-store.js +6 -5
  10. package/esm2015/operators/append.js +3 -3
  11. package/esm2015/operators/compose.js +1 -1
  12. package/esm2015/operators/iif.js +1 -1
  13. package/esm2015/operators/index.js +1 -1
  14. package/esm2015/operators/insert-item.js +3 -3
  15. package/esm2015/operators/patch.js +4 -5
  16. package/esm2015/operators/update-item.js +7 -5
  17. package/esm2015/operators/utils.js +1 -1
  18. package/esm2015/src/actions-stream.js +16 -6
  19. package/esm2015/src/internal/dispatcher.js +14 -36
  20. package/esm2015/src/internal/error-handler.js +118 -0
  21. package/esm2015/src/internal/internals.js +2 -27
  22. package/esm2015/src/internal/lifecycle-state-manager.js +85 -38
  23. package/esm2015/src/internal/state-context-factory.js +1 -12
  24. package/esm2015/src/internal/state-factory.js +4 -4
  25. package/esm2015/src/operators/of-action.js +7 -1
  26. package/esm2015/src/public_api.js +1 -1
  27. package/esm5/ngxs-store.js +6 -5
  28. package/esm5/operators/append.js +3 -3
  29. package/esm5/operators/compose.js +1 -1
  30. package/esm5/operators/iif.js +1 -1
  31. package/esm5/operators/index.js +1 -1
  32. package/esm5/operators/insert-item.js +3 -3
  33. package/esm5/operators/patch.js +4 -5
  34. package/esm5/operators/update-item.js +7 -5
  35. package/esm5/operators/utils.js +1 -1
  36. package/esm5/src/actions-stream.js +22 -7
  37. package/esm5/src/internal/dispatcher.js +13 -37
  38. package/esm5/src/internal/error-handler.js +125 -0
  39. package/esm5/src/internal/internals.js +2 -27
  40. package/esm5/src/internal/lifecycle-state-manager.js +97 -50
  41. package/esm5/src/internal/state-context-factory.js +1 -12
  42. package/esm5/src/internal/state-factory.js +4 -4
  43. package/esm5/src/operators/of-action.js +7 -1
  44. package/esm5/src/public_api.js +1 -1
  45. package/fesm2015/ngxs-store-operators.js +13 -12
  46. package/fesm2015/ngxs-store-operators.js.map +1 -1
  47. package/fesm2015/ngxs-store.js +459 -343
  48. package/fesm2015/ngxs-store.js.map +1 -1
  49. package/fesm5/ngxs-store-operators.js +13 -12
  50. package/fesm5/ngxs-store-operators.js.map +1 -1
  51. package/fesm5/ngxs-store.js +608 -483
  52. package/fesm5/ngxs-store.js.map +1 -1
  53. package/ngxs-store.d.ts +6 -5
  54. package/ngxs-store.metadata.json +1 -1
  55. package/operators/append.d.ts +2 -2
  56. package/operators/compose.d.ts +2 -1
  57. package/operators/iif.d.ts +2 -2
  58. package/operators/index.d.ts +1 -1
  59. package/operators/insert-item.d.ts +2 -2
  60. package/operators/ngxs-store-operators.metadata.json +1 -1
  61. package/operators/patch.d.ts +2 -6
  62. package/operators/update-item.d.ts +2 -2
  63. package/operators/utils.d.ts +2 -1
  64. package/package.json +3 -3
  65. package/src/actions-stream.d.ts +4 -2
  66. package/src/internal/dispatcher.d.ts +3 -4
  67. package/src/internal/error-handler.d.ts +23 -0
  68. package/src/internal/internals.d.ts +1 -6
  69. package/src/internal/lifecycle-state-manager.d.ts +16 -15
  70. package/src/operators/of-action.d.ts +20 -7
  71. package/src/public_api.d.ts +1 -1
@@ -1,9 +1,9 @@
1
- import { __assign, __spread, __extends, __values } from 'tslib';
2
- import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, Optional, SkipSelf, ErrorHandler, Injector, ɵivyEnabled, NgModule, APP_BOOTSTRAP_LISTENER } from '@angular/core';
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, observeOn, distinctUntilChanged } from 'rxjs/operators';
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$1(obj) {
980
+ function isObject(obj) {
1142
981
  return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
1143
982
  }
983
+
1144
984
  /**
1145
- * @template T
1146
- * @param {?} mappedStore
1147
- * @param {?} diff
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 getStateDiffChanges(mappedStore, diff) {
1151
- /** @type {?} */
1152
- var previousValue = getValue(diff.currentAppState, mappedStore.path);
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 currentValue = getValue(diff.newAppState, mappedStore.path);
1155
- return new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
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
@@ -1174,6 +1150,7 @@ if (false) {
1174
1150
  * RxJS operator for selecting out specific actions.
1175
1151
  *
1176
1152
  * This will grab actions that have just been dispatched as well as actions that have completed
1153
+ * @template T
1177
1154
  * @param {...?} allowedTypes
1178
1155
  * @return {?}
1179
1156
  */
@@ -1188,6 +1165,7 @@ function ofAction() {
1188
1165
  * RxJS operator for selecting out specific actions.
1189
1166
  *
1190
1167
  * This will ONLY grab actions that have just been dispatched
1168
+ * @template T
1191
1169
  * @param {...?} allowedTypes
1192
1170
  * @return {?}
1193
1171
  */
@@ -1202,6 +1180,7 @@ function ofActionDispatched() {
1202
1180
  * RxJS operator for selecting out specific actions.
1203
1181
  *
1204
1182
  * This will ONLY grab actions that have just been successfully completed
1183
+ * @template T
1205
1184
  * @param {...?} allowedTypes
1206
1185
  * @return {?}
1207
1186
  */
@@ -1216,6 +1195,7 @@ function ofActionSuccessful() {
1216
1195
  * RxJS operator for selecting out specific actions.
1217
1196
  *
1218
1197
  * This will ONLY grab actions that have just been canceled
1198
+ * @template T
1219
1199
  * @param {...?} allowedTypes
1220
1200
  * @return {?}
1221
1201
  */
@@ -1230,6 +1210,7 @@ function ofActionCanceled() {
1230
1210
  * RxJS operator for selecting out specific actions.
1231
1211
  *
1232
1212
  * This will ONLY grab actions that have just been completed
1213
+ * @template T
1233
1214
  * @param {...?} allowedTypes
1234
1215
  * @return {?}
1235
1216
  */
@@ -1250,6 +1231,7 @@ function ofActionCompleted() {
1250
1231
  * RxJS operator for selecting out specific actions.
1251
1232
  *
1252
1233
  * This will ONLY grab actions that have just thrown an error
1234
+ * @template T
1253
1235
  * @param {...?} allowedTypes
1254
1236
  * @return {?}
1255
1237
  */
@@ -1586,6 +1568,15 @@ var InternalActions = /** @class */ (function (_super) {
1586
1568
  function InternalActions() {
1587
1569
  return _super !== null && _super.apply(this, arguments) || this;
1588
1570
  }
1571
+ /**
1572
+ * @return {?}
1573
+ */
1574
+ InternalActions.prototype.ngOnDestroy = /**
1575
+ * @return {?}
1576
+ */
1577
+ function () {
1578
+ this.complete();
1579
+ };
1589
1580
  InternalActions.decorators = [
1590
1581
  { type: Injectable }
1591
1582
  ];
@@ -1598,18 +1589,22 @@ var InternalActions = /** @class */ (function (_super) {
1598
1589
  */
1599
1590
  var Actions = /** @class */ (function (_super) {
1600
1591
  __extends(Actions, _super);
1601
- // This has to be `Observable<ActionContext>` in the v4. Because `InternalActions`
1602
- // is a `Subject<ActionContext>`. Leave it as `any` to avoid breaking changes
1603
1592
  function Actions(internalActions$, internalExecutionStrategy) {
1604
- return _super.call(this, (/**
1593
+ var _this = this;
1594
+ /** @type {?} */
1595
+ var sharedInternalActions$ = internalActions$.pipe(leaveNgxs(internalExecutionStrategy),
1596
+ // The `InternalActions` subject emits outside of the Angular zone.
1597
+ // We have to re-enter the Angular zone for any incoming consumer.
1598
+ // The `share()` operator reduces the number of change detections.
1599
+ // This would call leave only once for any stream emission across all active subscribers.
1600
+ share());
1601
+ _this = _super.call(this, (/**
1605
1602
  * @param {?} observer
1606
1603
  * @return {?}
1607
1604
  */
1608
1605
  function (observer) {
1609
1606
  /** @type {?} */
1610
- var childSubscription = internalActions$
1611
- .pipe(leaveNgxs(internalExecutionStrategy))
1612
- .subscribe({
1607
+ var childSubscription = sharedInternalActions$.subscribe({
1613
1608
  next: (/**
1614
1609
  * @param {?} ctx
1615
1610
  * @return {?}
@@ -1627,6 +1622,7 @@ var Actions = /** @class */ (function (_super) {
1627
1622
  });
1628
1623
  observer.add(childSubscription);
1629
1624
  })) || this;
1625
+ return _this;
1630
1626
  }
1631
1627
  Actions.decorators = [
1632
1628
  { type: Injectable }
@@ -1693,6 +1689,126 @@ function () {
1693
1689
  })]));
1694
1690
  }); });
1695
1691
 
1692
+ /**
1693
+ * @fileoverview added by tsickle
1694
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1695
+ */
1696
+ /**
1697
+ * This operator is used for piping the observable result
1698
+ * from the `dispatch()`. It has a "smart" error handling
1699
+ * strategy that allows us to decide whether we propagate
1700
+ * errors to Angular's `ErrorHandler` or enable users to
1701
+ * handle them manually. We consider following cases:
1702
+ * 1) `store.dispatch()` (no subscribe) -> call `handleError()`
1703
+ * 2) `store.dispatch().subscribe()` (no error callback) -> call `handleError()`
1704
+ * 3) `store.dispatch().subscribe({ error: ... })` -> don't call `handleError()`
1705
+ * 4) `toPromise()` without `catch` -> do `handleError()`
1706
+ * 5) `toPromise()` with `catch` -> don't `handleError()`
1707
+ * @template T
1708
+ * @param {?} internalErrorReporter
1709
+ * @param {?} ngxsExecutionStrategy
1710
+ * @return {?}
1711
+ */
1712
+ function ngxsErrorHandler(internalErrorReporter, ngxsExecutionStrategy) {
1713
+ return (/**
1714
+ * @param {?} source
1715
+ * @return {?}
1716
+ */
1717
+ function (source) {
1718
+ /** @type {?} */
1719
+ var subscribed = false;
1720
+ source.subscribe({
1721
+ error: (/**
1722
+ * @param {?} error
1723
+ * @return {?}
1724
+ */
1725
+ function (error) {
1726
+ // Do not trigger change detection for a microtask. This depends on the execution
1727
+ // strategy being used, but the default `DispatchOutsideZoneNgxsExecutionStrategy`
1728
+ // leaves the Angular zone.
1729
+ ngxsExecutionStrategy.enter((/**
1730
+ * @return {?}
1731
+ */
1732
+ function () {
1733
+ return Promise.resolve().then((/**
1734
+ * @return {?}
1735
+ */
1736
+ function () {
1737
+ if (!subscribed) {
1738
+ ngxsExecutionStrategy.leave((/**
1739
+ * @return {?}
1740
+ */
1741
+ function () {
1742
+ return internalErrorReporter.reportErrorSafely(error);
1743
+ }));
1744
+ }
1745
+ }));
1746
+ }));
1747
+ })
1748
+ });
1749
+ return new Observable((/**
1750
+ * @param {?} subscriber
1751
+ * @return {?}
1752
+ */
1753
+ function (subscriber) {
1754
+ subscribed = true;
1755
+ return source.pipe(leaveNgxs(ngxsExecutionStrategy)).subscribe(subscriber);
1756
+ }));
1757
+ });
1758
+ }
1759
+ var InternalErrorReporter = /** @class */ (function () {
1760
+ function InternalErrorReporter(_injector) {
1761
+ this._injector = _injector;
1762
+ /**
1763
+ * Will be set lazily to be backward compatible.
1764
+ */
1765
+ this._errorHandler = (/** @type {?} */ (null));
1766
+ }
1767
+ /**
1768
+ * @param {?} error
1769
+ * @return {?}
1770
+ */
1771
+ InternalErrorReporter.prototype.reportErrorSafely = /**
1772
+ * @param {?} error
1773
+ * @return {?}
1774
+ */
1775
+ function (error) {
1776
+ if (this._errorHandler === null) {
1777
+ this._errorHandler = this._injector.get(ErrorHandler);
1778
+ }
1779
+ // The `try-catch` is used to avoid handling the error twice. Suppose we call
1780
+ // `handleError` which re-throws the error internally. The re-thrown error will
1781
+ // be caught by zone.js which will then get to the `zone.onError.emit()` and the
1782
+ // `onError` subscriber will call `handleError` again.
1783
+ try {
1784
+ this._errorHandler.handleError(error);
1785
+ }
1786
+ catch (_a) { }
1787
+ };
1788
+ InternalErrorReporter.decorators = [
1789
+ { type: Injectable, args: [{ providedIn: 'root' },] }
1790
+ ];
1791
+ /** @nocollapse */
1792
+ InternalErrorReporter.ctorParameters = function () { return [
1793
+ { type: Injector }
1794
+ ]; };
1795
+ /** @nocollapse */ InternalErrorReporter.ngInjectableDef = defineInjectable({ factory: function InternalErrorReporter_Factory() { return new InternalErrorReporter(inject(INJECTOR)); }, token: InternalErrorReporter, providedIn: "root" });
1796
+ return InternalErrorReporter;
1797
+ }());
1798
+ if (false) {
1799
+ /**
1800
+ * Will be set lazily to be backward compatible.
1801
+ * @type {?}
1802
+ * @private
1803
+ */
1804
+ InternalErrorReporter.prototype._errorHandler;
1805
+ /**
1806
+ * @type {?}
1807
+ * @private
1808
+ */
1809
+ InternalErrorReporter.prototype._injector;
1810
+ }
1811
+
1696
1812
  /**
1697
1813
  * @fileoverview added by tsickle
1698
1814
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -1825,13 +1941,13 @@ var InternalDispatchedActionResults = /** @class */ (function (_super) {
1825
1941
  return InternalDispatchedActionResults;
1826
1942
  }(Subject));
1827
1943
  var InternalDispatcher = /** @class */ (function () {
1828
- function InternalDispatcher(_injector, _actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy) {
1829
- this._injector = _injector;
1944
+ function InternalDispatcher(_actions, _actionResults, _pluginManager, _stateStream, _ngxsExecutionStrategy, _internalErrorReporter) {
1830
1945
  this._actions = _actions;
1831
1946
  this._actionResults = _actionResults;
1832
1947
  this._pluginManager = _pluginManager;
1833
1948
  this._stateStream = _stateStream;
1834
1949
  this._ngxsExecutionStrategy = _ngxsExecutionStrategy;
1950
+ this._internalErrorReporter = _internalErrorReporter;
1835
1951
  }
1836
1952
  /**
1837
1953
  * Dispatches event(s).
@@ -1855,26 +1971,7 @@ var InternalDispatcher = /** @class */ (function () {
1855
1971
  function () {
1856
1972
  return _this.dispatchByEvents(actionOrActions);
1857
1973
  }));
1858
- result.subscribe({
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));
1974
+ return result.pipe(ngxsErrorHandler(this._internalErrorReporter, this._ngxsExecutionStrategy));
1878
1975
  };
1879
1976
  /**
1880
1977
  * @private
@@ -1999,26 +2096,16 @@ var InternalDispatcher = /** @class */ (function () {
1999
2096
  ];
2000
2097
  /** @nocollapse */
2001
2098
  InternalDispatcher.ctorParameters = function () { return [
2002
- { type: Injector },
2003
2099
  { type: InternalActions },
2004
2100
  { type: InternalDispatchedActionResults },
2005
2101
  { type: PluginManager },
2006
2102
  { type: StateStream },
2007
- { type: InternalNgxsExecutionStrategy }
2103
+ { type: InternalNgxsExecutionStrategy },
2104
+ { type: InternalErrorReporter }
2008
2105
  ]; };
2009
2106
  return InternalDispatcher;
2010
2107
  }());
2011
2108
  if (false) {
2012
- /**
2013
- * @type {?}
2014
- * @private
2015
- */
2016
- InternalDispatcher.prototype._errorHandler;
2017
- /**
2018
- * @type {?}
2019
- * @private
2020
- */
2021
- InternalDispatcher.prototype._injector;
2022
2109
  /**
2023
2110
  * @type {?}
2024
2111
  * @private
@@ -2044,6 +2131,11 @@ if (false) {
2044
2131
  * @private
2045
2132
  */
2046
2133
  InternalDispatcher.prototype._ngxsExecutionStrategy;
2134
+ /**
2135
+ * @type {?}
2136
+ * @private
2137
+ */
2138
+ InternalDispatcher.prototype._internalErrorReporter;
2047
2139
  }
2048
2140
 
2049
2141
  /**
@@ -2285,16 +2377,6 @@ var StateContextFactory = /** @class */ (function () {
2285
2377
  function setStateValue(currentAppState, newValue) {
2286
2378
  /** @type {?} */
2287
2379
  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
2380
  root.setState(newAppState);
2299
2381
  return newAppState;
2300
2382
  // In doing this refactoring I noticed that there is a 'bug' where the
@@ -2608,7 +2690,7 @@ var StateFactory = /** @class */ (function () {
2608
2690
  if (Array.isArray(defaults)) {
2609
2691
  value = defaults.slice();
2610
2692
  }
2611
- else if (isObject$1(defaults)) {
2693
+ else if (isObject(defaults)) {
2612
2694
  value = __assign({}, defaults);
2613
2695
  }
2614
2696
  else if (defaults === undefined) {
@@ -2823,7 +2905,7 @@ var StateFactory = /** @class */ (function () {
2823
2905
  if (result instanceof Promise) {
2824
2906
  result = from(result);
2825
2907
  }
2826
- if (result instanceof Observable) {
2908
+ if (isObservable(result)) {
2827
2909
  // If this observable has been completed w/o emitting
2828
2910
  // any value then we wouldn't want to complete the whole chain
2829
2911
  // of actions. Since if any observable completes then
@@ -2840,7 +2922,7 @@ var StateFactory = /** @class */ (function () {
2840
2922
  if (value instanceof Promise) {
2841
2923
  return from(value);
2842
2924
  }
2843
- if (value instanceof Observable) {
2925
+ if (isObservable(value)) {
2844
2926
  return value;
2845
2927
  }
2846
2928
  return of(value);
@@ -2933,289 +3015,120 @@ var StateFactory = /** @class */ (function () {
2933
3015
  */
2934
3016
  StateFactory.prototype.addRuntimeInfoToMeta = /**
2935
3017
  * @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
- }
3018
+ * @param {?} meta
3019
+ * @param {?} path
3020
+ * @return {?}
3021
+ */
3022
+ function (meta, path) {
3023
+ this.statePaths[(/** @type {?} */ (meta.name))] = path;
3024
+ // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
3025
+ // we can do this when we get rid of the incorrectly exposed getStoreMetadata
3026
+ // We will need to come up with an alternative in v4 because this is used by many plugins
3027
+ meta.path = path;
3178
3028
  };
3179
3029
  /**
3030
+ * @description
3031
+ * the method checks if the state has already been added to the tree
3032
+ * and completed the life cycle
3033
+ * @param name
3034
+ * @param path
3035
+ */
3036
+ /**
3037
+ * \@description
3038
+ * the method checks if the state has already been added to the tree
3039
+ * and completed the life cycle
3180
3040
  * @private
3181
- * @param {?} mappedStore
3041
+ * @param {?} name
3042
+ * @param {?} path
3182
3043
  * @return {?}
3183
3044
  */
3184
- LifecycleStateManager.prototype.getStateContext = /**
3045
+ StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
3046
+ * \@description
3047
+ * the method checks if the state has already been added to the tree
3048
+ * and completed the life cycle
3185
3049
  * @private
3186
- * @param {?} mappedStore
3050
+ * @param {?} name
3051
+ * @param {?} path
3187
3052
  * @return {?}
3188
3053
  */
3189
- function (mappedStore) {
3190
- return this.stateContextFactory.createStateContext(mappedStore);
3054
+ function (name, path) {
3055
+ /** @type {?} */
3056
+ var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
3057
+ return this.statesByName[name] && valueIsBootstrappedInInitialState;
3191
3058
  };
3192
- LifecycleStateManager.decorators = [
3059
+ StateFactory.decorators = [
3193
3060
  { type: Injectable }
3194
3061
  ];
3195
3062
  /** @nocollapse */
3196
- LifecycleStateManager.ctorParameters = function () { return [
3197
- { type: InternalStateOperations },
3063
+ StateFactory.ctorParameters = function () { return [
3064
+ { type: Injector },
3065
+ { type: NgxsConfig },
3066
+ { type: StateFactory, decorators: [{ type: Optional }, { type: SkipSelf }] },
3067
+ { type: InternalActions },
3068
+ { type: InternalDispatchedActionResults },
3198
3069
  { type: StateContextFactory },
3199
- { type: NgxsBootstrapper }
3070
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
3200
3071
  ]; };
3201
- return LifecycleStateManager;
3072
+ return StateFactory;
3202
3073
  }());
3203
3074
  if (false) {
3204
3075
  /**
3205
3076
  * @type {?}
3206
3077
  * @private
3207
3078
  */
3208
- LifecycleStateManager.prototype.internalStateOperations;
3079
+ StateFactory.prototype._actionsSubscription;
3080
+ /**
3081
+ * @type {?}
3082
+ * @private
3083
+ */
3084
+ StateFactory.prototype._states;
3085
+ /**
3086
+ * @type {?}
3087
+ * @private
3088
+ */
3089
+ StateFactory.prototype._statesByName;
3090
+ /**
3091
+ * @type {?}
3092
+ * @private
3093
+ */
3094
+ StateFactory.prototype._statePaths;
3095
+ /** @type {?} */
3096
+ StateFactory.prototype.getRuntimeSelectorContext;
3097
+ /**
3098
+ * @type {?}
3099
+ * @private
3100
+ */
3101
+ StateFactory.prototype._injector;
3102
+ /**
3103
+ * @type {?}
3104
+ * @private
3105
+ */
3106
+ StateFactory.prototype._config;
3107
+ /**
3108
+ * @type {?}
3109
+ * @private
3110
+ */
3111
+ StateFactory.prototype._parentFactory;
3112
+ /**
3113
+ * @type {?}
3114
+ * @private
3115
+ */
3116
+ StateFactory.prototype._actions;
3117
+ /**
3118
+ * @type {?}
3119
+ * @private
3120
+ */
3121
+ StateFactory.prototype._actionResults;
3209
3122
  /**
3210
3123
  * @type {?}
3211
3124
  * @private
3212
3125
  */
3213
- LifecycleStateManager.prototype.stateContextFactory;
3126
+ StateFactory.prototype._stateContextFactory;
3214
3127
  /**
3215
3128
  * @type {?}
3216
3129
  * @private
3217
3130
  */
3218
- LifecycleStateManager.prototype.bootstrapper;
3131
+ StateFactory.prototype._initialState;
3219
3132
  }
3220
3133
 
3221
3134
  /**
@@ -3672,6 +3585,218 @@ if (false) {
3672
3585
  Store.prototype._stateFactory;
3673
3586
  }
3674
3587
 
3588
+ /**
3589
+ * @fileoverview added by tsickle
3590
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3591
+ */
3592
+ var LifecycleStateManager = /** @class */ (function () {
3593
+ function LifecycleStateManager(_store, _internalErrorReporter, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3594
+ this._store = _store;
3595
+ this._internalErrorReporter = _internalErrorReporter;
3596
+ this._internalStateOperations = _internalStateOperations;
3597
+ this._stateContextFactory = _stateContextFactory;
3598
+ this._bootstrapper = _bootstrapper;
3599
+ this._destroy$ = new Subject();
3600
+ }
3601
+ /**
3602
+ * @return {?}
3603
+ */
3604
+ LifecycleStateManager.prototype.ngOnDestroy = /**
3605
+ * @return {?}
3606
+ */
3607
+ function () {
3608
+ this._destroy$.next();
3609
+ };
3610
+ /**
3611
+ * @template T
3612
+ * @param {?} action
3613
+ * @param {?} results
3614
+ * @return {?}
3615
+ */
3616
+ LifecycleStateManager.prototype.ngxsBootstrap = /**
3617
+ * @template T
3618
+ * @param {?} action
3619
+ * @param {?} results
3620
+ * @return {?}
3621
+ */
3622
+ function (action, results) {
3623
+ var _this = this;
3624
+ this._internalStateOperations
3625
+ .getRootStateOperations()
3626
+ .dispatch(action)
3627
+ .pipe(filter((/**
3628
+ * @return {?}
3629
+ */
3630
+ function () { return !!results; })), tap((/**
3631
+ * @return {?}
3632
+ */
3633
+ function () { return _this._invokeInitOnStates((/** @type {?} */ (results)).states); })), mergeMap((/**
3634
+ * @return {?}
3635
+ */
3636
+ function () { return _this._bootstrapper.appBootstrapped$; })), filter((/**
3637
+ * @param {?} appBootstrapped
3638
+ * @return {?}
3639
+ */
3640
+ function (appBootstrapped) { return !!appBootstrapped; })), catchError((/**
3641
+ * @param {?} error
3642
+ * @return {?}
3643
+ */
3644
+ function (error) {
3645
+ // The `SafeSubscriber` (which is used by most RxJS operators) re-throws
3646
+ // errors asynchronously (`setTimeout(() => { throw error })`). This might
3647
+ // break existing user's code or unit tests. We catch the error manually to
3648
+ // be backward compatible with the old behavior.
3649
+ _this._internalErrorReporter.reportErrorSafely(error);
3650
+ return EMPTY;
3651
+ })), takeUntil(this._destroy$))
3652
+ .subscribe((/**
3653
+ * @return {?}
3654
+ */
3655
+ function () { return _this._invokeBootstrapOnStates((/** @type {?} */ (results)).states); }));
3656
+ };
3657
+ /**
3658
+ * @private
3659
+ * @param {?} mappedStores
3660
+ * @return {?}
3661
+ */
3662
+ LifecycleStateManager.prototype._invokeInitOnStates = /**
3663
+ * @private
3664
+ * @param {?} mappedStores
3665
+ * @return {?}
3666
+ */
3667
+ function (mappedStores) {
3668
+ var e_1, _a;
3669
+ var _loop_1 = function (mappedStore) {
3670
+ /** @type {?} */
3671
+ var instance = mappedStore.instance;
3672
+ if (instance.ngxsOnChanges) {
3673
+ this_1._store
3674
+ .select((/**
3675
+ * @param {?} state
3676
+ * @return {?}
3677
+ */
3678
+ function (state) { return getValue(state, mappedStore.path); }))
3679
+ .pipe(startWith(undefined), pairwise(), takeUntil(this_1._destroy$))
3680
+ .subscribe((/**
3681
+ * @param {?} __0
3682
+ * @return {?}
3683
+ */
3684
+ function (_a) {
3685
+ var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
3686
+ /** @type {?} */
3687
+ var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
3688
+ (/** @type {?} */ (instance.ngxsOnChanges))(change);
3689
+ }));
3690
+ }
3691
+ if (instance.ngxsOnInit) {
3692
+ instance.ngxsOnInit(this_1._getStateContext(mappedStore));
3693
+ }
3694
+ mappedStore.isInitialised = true;
3695
+ };
3696
+ var this_1 = this;
3697
+ try {
3698
+ for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3699
+ var mappedStore = mappedStores_1_1.value;
3700
+ _loop_1(mappedStore);
3701
+ }
3702
+ }
3703
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3704
+ finally {
3705
+ try {
3706
+ if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3707
+ }
3708
+ finally { if (e_1) throw e_1.error; }
3709
+ }
3710
+ };
3711
+ /**
3712
+ * @private
3713
+ * @param {?} mappedStores
3714
+ * @return {?}
3715
+ */
3716
+ LifecycleStateManager.prototype._invokeBootstrapOnStates = /**
3717
+ * @private
3718
+ * @param {?} mappedStores
3719
+ * @return {?}
3720
+ */
3721
+ function (mappedStores) {
3722
+ var e_2, _a;
3723
+ try {
3724
+ for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3725
+ var mappedStore = mappedStores_2_1.value;
3726
+ /** @type {?} */
3727
+ var instance = mappedStore.instance;
3728
+ if (instance.ngxsAfterBootstrap) {
3729
+ instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
3730
+ }
3731
+ }
3732
+ }
3733
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3734
+ finally {
3735
+ try {
3736
+ if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3737
+ }
3738
+ finally { if (e_2) throw e_2.error; }
3739
+ }
3740
+ };
3741
+ /**
3742
+ * @private
3743
+ * @param {?} mappedStore
3744
+ * @return {?}
3745
+ */
3746
+ LifecycleStateManager.prototype._getStateContext = /**
3747
+ * @private
3748
+ * @param {?} mappedStore
3749
+ * @return {?}
3750
+ */
3751
+ function (mappedStore) {
3752
+ return this._stateContextFactory.createStateContext(mappedStore);
3753
+ };
3754
+ LifecycleStateManager.decorators = [
3755
+ { type: Injectable }
3756
+ ];
3757
+ /** @nocollapse */
3758
+ LifecycleStateManager.ctorParameters = function () { return [
3759
+ { type: Store },
3760
+ { type: InternalErrorReporter },
3761
+ { type: InternalStateOperations },
3762
+ { type: StateContextFactory },
3763
+ { type: NgxsBootstrapper }
3764
+ ]; };
3765
+ return LifecycleStateManager;
3766
+ }());
3767
+ if (false) {
3768
+ /**
3769
+ * @type {?}
3770
+ * @private
3771
+ */
3772
+ LifecycleStateManager.prototype._destroy$;
3773
+ /**
3774
+ * @type {?}
3775
+ * @private
3776
+ */
3777
+ LifecycleStateManager.prototype._store;
3778
+ /**
3779
+ * @type {?}
3780
+ * @private
3781
+ */
3782
+ LifecycleStateManager.prototype._internalErrorReporter;
3783
+ /**
3784
+ * @type {?}
3785
+ * @private
3786
+ */
3787
+ LifecycleStateManager.prototype._internalStateOperations;
3788
+ /**
3789
+ * @type {?}
3790
+ * @private
3791
+ */
3792
+ LifecycleStateManager.prototype._stateContextFactory;
3793
+ /**
3794
+ * @type {?}
3795
+ * @private
3796
+ */
3797
+ LifecycleStateManager.prototype._bootstrapper;
3798
+ }
3799
+
3675
3800
  /**
3676
3801
  * @fileoverview added by tsickle
3677
3802
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -4494,5 +4619,5 @@ if (false) {
4494
4619
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
4495
4620
  */
4496
4621
 
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, SelectFactory as ɵr, ensureStoreMetadata as ɵt, getStoreMetadata as ɵu, ensureSelectorMetadata as ɵv, getSelectorMetadata as ɵw, LifecycleStateManager as ɵx, NgxsFeatureModule as ɵy };
4622
+ 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
4623
  //# sourceMappingURL=ngxs-store.js.map