@ngxs/store 3.7.5-dev.master-708406e → 3.7.5-dev.master-f9549a3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
- import { __assign, __spread, __extends, __values } from 'tslib';
1
+ import { __assign, __spread, __extends, __values, __read } from 'tslib';
2
2
  import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, InjectionToken, INJECTOR, ɵglobal, Optional, SkipSelf, ErrorHandler, Injector, ɵ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
5
  import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable, queueScheduler } from 'rxjs';
6
- import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap, observeOn, distinctUntilChanged } from 'rxjs/operators';
6
+ import { filter, map, 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
  *
@@ -1134,26 +973,163 @@ function topologicalSort(graph) {
1134
973
  /**
1135
974
  * Returns if the parameter is a object or not.
1136
975
  *
1137
- * @ignore
1138
- * @param {?} obj
1139
- * @return {?}
976
+ * @ignore
977
+ * @param {?} obj
978
+ * @return {?}
979
+ */
980
+ function isObject(obj) {
981
+ return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
982
+ }
983
+
984
+ /**
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
992
+ * @return {?}
993
+ */
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) {
1009
+ /** @type {?} */
1010
+ var type1 = getActionTypeFromInstance(action1);
1011
+ return (/**
1012
+ * @param {?} action2
1013
+ * @return {?}
1014
+ */
1015
+ function (action2) {
1016
+ return type1 === getActionTypeFromInstance(action2);
1017
+ });
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 {?}
1140
1103
  */
1141
- function isObject$1(obj) {
1142
- return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
1143
- }
1144
- /**
1145
- * @template T
1146
- * @param {?} mappedStore
1147
- * @param {?} diff
1104
+ var mergeDeep = (/**
1105
+ * @param {?} base
1106
+ * @param {...?} sources
1148
1107
  * @return {?}
1149
1108
  */
1150
- function getStateDiffChanges(mappedStore, diff) {
1151
- /** @type {?} */
1152
- var previousValue = getValue(diff.currentAppState, mappedStore.path);
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;
1153
1117
  /** @type {?} */
1154
- var currentValue = getValue(diff.newAppState, mappedStore.path);
1155
- return new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
1156
- }
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
@@ -2289,16 +2265,6 @@ var StateContextFactory = /** @class */ (function () {
2289
2265
  function setStateValue(currentAppState, newValue) {
2290
2266
  /** @type {?} */
2291
2267
  var newAppState = setValue(currentAppState, mappedStore.path, newValue);
2292
- /** @type {?} */
2293
- var instance = mappedStore.instance;
2294
- if (instance.ngxsOnChanges) {
2295
- /** @type {?} */
2296
- var change = getStateDiffChanges(mappedStore, {
2297
- currentAppState: currentAppState,
2298
- newAppState: newAppState
2299
- });
2300
- instance.ngxsOnChanges(change);
2301
- }
2302
2268
  root.setState(newAppState);
2303
2269
  return newAppState;
2304
2270
  // In doing this refactoring I noticed that there is a 'bug' where the
@@ -2612,7 +2578,7 @@ var StateFactory = /** @class */ (function () {
2612
2578
  if (Array.isArray(defaults)) {
2613
2579
  value = defaults.slice();
2614
2580
  }
2615
- else if (isObject$1(defaults)) {
2581
+ else if (isObject(defaults)) {
2616
2582
  value = __assign({}, defaults);
2617
2583
  }
2618
2584
  else if (defaults === undefined) {
@@ -2941,285 +2907,116 @@ var StateFactory = /** @class */ (function () {
2941
2907
  * @param {?} path
2942
2908
  * @return {?}
2943
2909
  */
2944
- function (meta, path) {
2945
- this.statePaths[(/** @type {?} */ (meta.name))] = path;
2946
- // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
2947
- // we can do this when we get rid of the incorrectly exposed getStoreMetadata
2948
- // We will need to come up with an alternative in v4 because this is used by many plugins
2949
- meta.path = path;
2950
- };
2951
- /**
2952
- * @description
2953
- * the method checks if the state has already been added to the tree
2954
- * and completed the life cycle
2955
- * @param name
2956
- * @param path
2957
- */
2958
- /**
2959
- * \@description
2960
- * the method checks if the state has already been added to the tree
2961
- * and completed the life cycle
2962
- * @private
2963
- * @param {?} name
2964
- * @param {?} path
2965
- * @return {?}
2966
- */
2967
- StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
2968
- * \@description
2969
- * the method checks if the state has already been added to the tree
2970
- * and completed the life cycle
2971
- * @private
2972
- * @param {?} name
2973
- * @param {?} path
2974
- * @return {?}
2975
- */
2976
- function (name, path) {
2977
- /** @type {?} */
2978
- var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
2979
- return this.statesByName[name] && valueIsBootstrappedInInitialState;
2980
- };
2981
- StateFactory.decorators = [
2982
- { type: Injectable }
2983
- ];
2984
- /** @nocollapse */
2985
- StateFactory.ctorParameters = function () { return [
2986
- { type: Injector },
2987
- { type: NgxsConfig },
2988
- { type: StateFactory, decorators: [{ type: Optional }, { type: SkipSelf }] },
2989
- { type: InternalActions },
2990
- { type: InternalDispatchedActionResults },
2991
- { type: StateContextFactory },
2992
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
2993
- ]; };
2994
- return StateFactory;
2995
- }());
2996
- if (false) {
2997
- /**
2998
- * @type {?}
2999
- * @private
3000
- */
3001
- StateFactory.prototype._actionsSubscription;
3002
- /**
3003
- * @type {?}
3004
- * @private
3005
- */
3006
- StateFactory.prototype._states;
3007
- /**
3008
- * @type {?}
3009
- * @private
3010
- */
3011
- StateFactory.prototype._statesByName;
3012
- /**
3013
- * @type {?}
3014
- * @private
3015
- */
3016
- StateFactory.prototype._statePaths;
3017
- /** @type {?} */
3018
- StateFactory.prototype.getRuntimeSelectorContext;
3019
- /**
3020
- * @type {?}
3021
- * @private
3022
- */
3023
- StateFactory.prototype._injector;
3024
- /**
3025
- * @type {?}
3026
- * @private
3027
- */
3028
- StateFactory.prototype._config;
3029
- /**
3030
- * @type {?}
3031
- * @private
3032
- */
3033
- StateFactory.prototype._parentFactory;
3034
- /**
3035
- * @type {?}
3036
- * @private
3037
- */
3038
- StateFactory.prototype._actions;
3039
- /**
3040
- * @type {?}
3041
- * @private
3042
- */
3043
- StateFactory.prototype._actionResults;
3044
- /**
3045
- * @type {?}
3046
- * @private
3047
- */
3048
- StateFactory.prototype._stateContextFactory;
3049
- /**
3050
- * @type {?}
3051
- * @private
3052
- */
3053
- StateFactory.prototype._initialState;
3054
- }
3055
-
3056
- /**
3057
- * @fileoverview added by tsickle
3058
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3059
- */
3060
- var LifecycleStateManager = /** @class */ (function () {
3061
- function LifecycleStateManager(internalStateOperations, stateContextFactory, bootstrapper) {
3062
- this.internalStateOperations = internalStateOperations;
3063
- this.stateContextFactory = stateContextFactory;
3064
- this.bootstrapper = bootstrapper;
3065
- }
3066
- /**
3067
- * @template T
3068
- * @param {?} action
3069
- * @param {?} results
3070
- * @return {?}
3071
- */
3072
- LifecycleStateManager.prototype.ngxsBootstrap = /**
3073
- * @template T
3074
- * @param {?} action
3075
- * @param {?} results
3076
- * @return {?}
3077
- */
3078
- function (action, results) {
3079
- var _this = this;
3080
- this.internalStateOperations
3081
- .getRootStateOperations()
3082
- .dispatch(action)
3083
- .pipe(filter((/**
3084
- * @return {?}
3085
- */
3086
- function () { return !!results; })), tap((/**
3087
- * @return {?}
3088
- */
3089
- function () { return _this.invokeInit((/** @type {?} */ (results)).states); })), mergeMap((/**
3090
- * @return {?}
3091
- */
3092
- function () { return _this.bootstrapper.appBootstrapped$; })), filter((/**
3093
- * @param {?} appBootstrapped
3094
- * @return {?}
3095
- */
3096
- function (appBootstrapped) { return !!appBootstrapped; })))
3097
- .subscribe((/**
3098
- * @return {?}
3099
- */
3100
- function () { return _this.invokeBootstrap((/** @type {?} */ (results)).states); }));
3101
- };
3102
- /**
3103
- * Invoke the init function on the states.
3104
- */
3105
- /**
3106
- * Invoke the init function on the states.
3107
- * @param {?} mappedStores
3108
- * @return {?}
3109
- */
3110
- LifecycleStateManager.prototype.invokeInit = /**
3111
- * Invoke the init function on the states.
3112
- * @param {?} mappedStores
3113
- * @return {?}
3114
- */
3115
- function (mappedStores) {
3116
- var e_1, _a;
3117
- try {
3118
- for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3119
- var mappedStore = mappedStores_1_1.value;
3120
- /** @type {?} */
3121
- var instance = mappedStore.instance;
3122
- if (instance.ngxsOnChanges) {
3123
- /** @type {?} */
3124
- var currentAppState = {};
3125
- /** @type {?} */
3126
- var newAppState = this.internalStateOperations
3127
- .getRootStateOperations()
3128
- .getState();
3129
- /** @type {?} */
3130
- var firstDiffChange = getStateDiffChanges(mappedStore, {
3131
- currentAppState: currentAppState,
3132
- newAppState: newAppState
3133
- });
3134
- instance.ngxsOnChanges(firstDiffChange);
3135
- }
3136
- if (instance.ngxsOnInit) {
3137
- instance.ngxsOnInit(this.getStateContext(mappedStore));
3138
- }
3139
- mappedStore.isInitialised = true;
3140
- }
3141
- }
3142
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3143
- finally {
3144
- try {
3145
- if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3146
- }
3147
- finally { if (e_1) throw e_1.error; }
3148
- }
3149
- };
3150
- /**
3151
- * Invoke the bootstrap function on the states.
3152
- */
3153
- /**
3154
- * Invoke the bootstrap function on the states.
3155
- * @param {?} mappedStores
3156
- * @return {?}
3157
- */
3158
- LifecycleStateManager.prototype.invokeBootstrap = /**
3159
- * Invoke the bootstrap function on the states.
3160
- * @param {?} mappedStores
3161
- * @return {?}
3162
- */
3163
- function (mappedStores) {
3164
- var e_2, _a;
3165
- try {
3166
- for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3167
- var mappedStore = mappedStores_2_1.value;
3168
- /** @type {?} */
3169
- var instance = mappedStore.instance;
3170
- if (instance.ngxsAfterBootstrap) {
3171
- instance.ngxsAfterBootstrap(this.getStateContext(mappedStore));
3172
- }
3173
- }
3174
- }
3175
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3176
- finally {
3177
- try {
3178
- if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3179
- }
3180
- finally { if (e_2) throw e_2.error; }
3181
- }
2910
+ function (meta, path) {
2911
+ this.statePaths[(/** @type {?} */ (meta.name))] = path;
2912
+ // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
2913
+ // we can do this when we get rid of the incorrectly exposed getStoreMetadata
2914
+ // We will need to come up with an alternative in v4 because this is used by many plugins
2915
+ meta.path = path;
3182
2916
  };
3183
2917
  /**
2918
+ * @description
2919
+ * the method checks if the state has already been added to the tree
2920
+ * and completed the life cycle
2921
+ * @param name
2922
+ * @param path
2923
+ */
2924
+ /**
2925
+ * \@description
2926
+ * the method checks if the state has already been added to the tree
2927
+ * and completed the life cycle
3184
2928
  * @private
3185
- * @param {?} mappedStore
2929
+ * @param {?} name
2930
+ * @param {?} path
3186
2931
  * @return {?}
3187
2932
  */
3188
- LifecycleStateManager.prototype.getStateContext = /**
2933
+ StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
2934
+ * \@description
2935
+ * the method checks if the state has already been added to the tree
2936
+ * and completed the life cycle
3189
2937
  * @private
3190
- * @param {?} mappedStore
2938
+ * @param {?} name
2939
+ * @param {?} path
3191
2940
  * @return {?}
3192
2941
  */
3193
- function (mappedStore) {
3194
- return this.stateContextFactory.createStateContext(mappedStore);
2942
+ function (name, path) {
2943
+ /** @type {?} */
2944
+ var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
2945
+ return this.statesByName[name] && valueIsBootstrappedInInitialState;
3195
2946
  };
3196
- LifecycleStateManager.decorators = [
2947
+ StateFactory.decorators = [
3197
2948
  { type: Injectable }
3198
2949
  ];
3199
2950
  /** @nocollapse */
3200
- LifecycleStateManager.ctorParameters = function () { return [
3201
- { type: InternalStateOperations },
2951
+ StateFactory.ctorParameters = function () { return [
2952
+ { type: Injector },
2953
+ { type: NgxsConfig },
2954
+ { type: StateFactory, decorators: [{ type: Optional }, { type: SkipSelf }] },
2955
+ { type: InternalActions },
2956
+ { type: InternalDispatchedActionResults },
3202
2957
  { type: StateContextFactory },
3203
- { type: NgxsBootstrapper }
2958
+ { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [INITIAL_STATE_TOKEN,] }] }
3204
2959
  ]; };
3205
- return LifecycleStateManager;
2960
+ return StateFactory;
3206
2961
  }());
3207
2962
  if (false) {
3208
2963
  /**
3209
2964
  * @type {?}
3210
2965
  * @private
3211
2966
  */
3212
- LifecycleStateManager.prototype.internalStateOperations;
2967
+ StateFactory.prototype._actionsSubscription;
2968
+ /**
2969
+ * @type {?}
2970
+ * @private
2971
+ */
2972
+ StateFactory.prototype._states;
2973
+ /**
2974
+ * @type {?}
2975
+ * @private
2976
+ */
2977
+ StateFactory.prototype._statesByName;
2978
+ /**
2979
+ * @type {?}
2980
+ * @private
2981
+ */
2982
+ StateFactory.prototype._statePaths;
2983
+ /** @type {?} */
2984
+ StateFactory.prototype.getRuntimeSelectorContext;
2985
+ /**
2986
+ * @type {?}
2987
+ * @private
2988
+ */
2989
+ StateFactory.prototype._injector;
2990
+ /**
2991
+ * @type {?}
2992
+ * @private
2993
+ */
2994
+ StateFactory.prototype._config;
2995
+ /**
2996
+ * @type {?}
2997
+ * @private
2998
+ */
2999
+ StateFactory.prototype._parentFactory;
3000
+ /**
3001
+ * @type {?}
3002
+ * @private
3003
+ */
3004
+ StateFactory.prototype._actions;
3005
+ /**
3006
+ * @type {?}
3007
+ * @private
3008
+ */
3009
+ StateFactory.prototype._actionResults;
3213
3010
  /**
3214
3011
  * @type {?}
3215
3012
  * @private
3216
3013
  */
3217
- LifecycleStateManager.prototype.stateContextFactory;
3014
+ StateFactory.prototype._stateContextFactory;
3218
3015
  /**
3219
3016
  * @type {?}
3220
3017
  * @private
3221
3018
  */
3222
- LifecycleStateManager.prototype.bootstrapper;
3019
+ StateFactory.prototype._initialState;
3223
3020
  }
3224
3021
 
3225
3022
  /**
@@ -3676,6 +3473,210 @@ if (false) {
3676
3473
  Store.prototype._stateFactory;
3677
3474
  }
3678
3475
 
3476
+ /**
3477
+ * @fileoverview added by tsickle
3478
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3479
+ */
3480
+ var LifecycleStateManager = /** @class */ (function () {
3481
+ function LifecycleStateManager(_store, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3482
+ this._store = _store;
3483
+ this._internalStateOperations = _internalStateOperations;
3484
+ this._stateContextFactory = _stateContextFactory;
3485
+ this._bootstrapper = _bootstrapper;
3486
+ this._destroy$ = new Subject();
3487
+ }
3488
+ /**
3489
+ * @return {?}
3490
+ */
3491
+ LifecycleStateManager.prototype.ngOnDestroy = /**
3492
+ * @return {?}
3493
+ */
3494
+ function () {
3495
+ this._destroy$.next();
3496
+ };
3497
+ /**
3498
+ * @template T
3499
+ * @param {?} action
3500
+ * @param {?} results
3501
+ * @return {?}
3502
+ */
3503
+ LifecycleStateManager.prototype.ngxsBootstrap = /**
3504
+ * @template T
3505
+ * @param {?} action
3506
+ * @param {?} results
3507
+ * @return {?}
3508
+ */
3509
+ function (action, results) {
3510
+ var _this = this;
3511
+ this._internalStateOperations
3512
+ .getRootStateOperations()
3513
+ .dispatch(action)
3514
+ .pipe(filter((/**
3515
+ * @return {?}
3516
+ */
3517
+ function () { return !!results; })), tap((/**
3518
+ * @return {?}
3519
+ */
3520
+ function () { return _this._invokeInit((/** @type {?} */ (results)).states); })), mergeMap((/**
3521
+ * @return {?}
3522
+ */
3523
+ function () { return _this._bootstrapper.appBootstrapped$; })), filter((/**
3524
+ * @param {?} appBootstrapped
3525
+ * @return {?}
3526
+ */
3527
+ function (appBootstrapped) { return !!appBootstrapped; })), takeUntil(this._destroy$))
3528
+ .subscribe((/**
3529
+ * @return {?}
3530
+ */
3531
+ function () { return _this._invokeBootstrap((/** @type {?} */ (results)).states); }));
3532
+ };
3533
+ /**
3534
+ * Invoke the init function on the states.
3535
+ */
3536
+ /**
3537
+ * Invoke the init function on the states.
3538
+ * @private
3539
+ * @param {?} mappedStores
3540
+ * @return {?}
3541
+ */
3542
+ LifecycleStateManager.prototype._invokeInit = /**
3543
+ * Invoke the init function on the states.
3544
+ * @private
3545
+ * @param {?} mappedStores
3546
+ * @return {?}
3547
+ */
3548
+ function (mappedStores) {
3549
+ var e_1, _a;
3550
+ var _loop_1 = function (mappedStore) {
3551
+ /** @type {?} */
3552
+ var instance = mappedStore.instance;
3553
+ if (instance.ngxsOnChanges) {
3554
+ this_1._store
3555
+ .select((/**
3556
+ * @param {?} state
3557
+ * @return {?}
3558
+ */
3559
+ function (state) { return getValue(state, mappedStore.path); }))
3560
+ .pipe(startWith(undefined), pairwise(), takeUntil(this_1._destroy$))
3561
+ .subscribe((/**
3562
+ * @param {?} __0
3563
+ * @return {?}
3564
+ */
3565
+ function (_a) {
3566
+ var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
3567
+ /** @type {?} */
3568
+ var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
3569
+ (/** @type {?} */ (instance.ngxsOnChanges))(change);
3570
+ }));
3571
+ }
3572
+ if (instance.ngxsOnInit) {
3573
+ instance.ngxsOnInit(this_1._getStateContext(mappedStore));
3574
+ }
3575
+ mappedStore.isInitialised = true;
3576
+ };
3577
+ var this_1 = this;
3578
+ try {
3579
+ for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3580
+ var mappedStore = mappedStores_1_1.value;
3581
+ _loop_1(mappedStore);
3582
+ }
3583
+ }
3584
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3585
+ finally {
3586
+ try {
3587
+ if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3588
+ }
3589
+ finally { if (e_1) throw e_1.error; }
3590
+ }
3591
+ };
3592
+ /**
3593
+ * Invoke the bootstrap function on the states.
3594
+ */
3595
+ /**
3596
+ * Invoke the bootstrap function on the states.
3597
+ * @private
3598
+ * @param {?} mappedStores
3599
+ * @return {?}
3600
+ */
3601
+ LifecycleStateManager.prototype._invokeBootstrap = /**
3602
+ * Invoke the bootstrap function on the states.
3603
+ * @private
3604
+ * @param {?} mappedStores
3605
+ * @return {?}
3606
+ */
3607
+ function (mappedStores) {
3608
+ var e_2, _a;
3609
+ try {
3610
+ for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3611
+ var mappedStore = mappedStores_2_1.value;
3612
+ /** @type {?} */
3613
+ var instance = mappedStore.instance;
3614
+ if (instance.ngxsAfterBootstrap) {
3615
+ instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
3616
+ }
3617
+ }
3618
+ }
3619
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3620
+ finally {
3621
+ try {
3622
+ if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3623
+ }
3624
+ finally { if (e_2) throw e_2.error; }
3625
+ }
3626
+ };
3627
+ /**
3628
+ * @private
3629
+ * @param {?} mappedStore
3630
+ * @return {?}
3631
+ */
3632
+ LifecycleStateManager.prototype._getStateContext = /**
3633
+ * @private
3634
+ * @param {?} mappedStore
3635
+ * @return {?}
3636
+ */
3637
+ function (mappedStore) {
3638
+ return this._stateContextFactory.createStateContext(mappedStore);
3639
+ };
3640
+ LifecycleStateManager.decorators = [
3641
+ { type: Injectable }
3642
+ ];
3643
+ /** @nocollapse */
3644
+ LifecycleStateManager.ctorParameters = function () { return [
3645
+ { type: Store },
3646
+ { type: InternalStateOperations },
3647
+ { type: StateContextFactory },
3648
+ { type: NgxsBootstrapper }
3649
+ ]; };
3650
+ return LifecycleStateManager;
3651
+ }());
3652
+ if (false) {
3653
+ /**
3654
+ * @type {?}
3655
+ * @private
3656
+ */
3657
+ LifecycleStateManager.prototype._destroy$;
3658
+ /**
3659
+ * @type {?}
3660
+ * @private
3661
+ */
3662
+ LifecycleStateManager.prototype._store;
3663
+ /**
3664
+ * @type {?}
3665
+ * @private
3666
+ */
3667
+ LifecycleStateManager.prototype._internalStateOperations;
3668
+ /**
3669
+ * @type {?}
3670
+ * @private
3671
+ */
3672
+ LifecycleStateManager.prototype._stateContextFactory;
3673
+ /**
3674
+ * @type {?}
3675
+ * @private
3676
+ */
3677
+ LifecycleStateManager.prototype._bootstrapper;
3678
+ }
3679
+
3679
3680
  /**
3680
3681
  * @fileoverview added by tsickle
3681
3682
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc