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

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.
@@ -730,156 +730,6 @@
730
730
  NgxsExecutionStrategy.prototype.leave = function (func) { };
731
731
  }
732
732
 
733
- /**
734
- * @fileoverview added by tsickle
735
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
736
- */
737
- /**
738
- * Returns the type from an action instance/class.
739
- * @ignore
740
- * @param {?} action
741
- * @return {?}
742
- */
743
- function getActionTypeFromInstance(action) {
744
- if (action.constructor && action.constructor.type) {
745
- return action.constructor.type;
746
- }
747
- else {
748
- return action.type;
749
- }
750
- }
751
- /**
752
- * Matches a action
753
- * @ignore
754
- * @param {?} action1
755
- * @return {?}
756
- */
757
- function actionMatcher(action1) {
758
- /** @type {?} */
759
- var type1 = getActionTypeFromInstance(action1);
760
- return (/**
761
- * @param {?} action2
762
- * @return {?}
763
- */
764
- function (action2) {
765
- return type1 === getActionTypeFromInstance(action2);
766
- });
767
- }
768
- /**
769
- * Set a deeply nested value. Example:
770
- *
771
- * setValue({ foo: { bar: { eat: false } } },
772
- * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
773
- *
774
- * While it traverses it also creates new objects from top down.
775
- *
776
- * @ignore
777
- * @type {?}
778
- */
779
- var setValue = (/**
780
- * @param {?} obj
781
- * @param {?} prop
782
- * @param {?} val
783
- * @return {?}
784
- */
785
- function (obj, prop, val) {
786
- obj = __assign({}, obj);
787
- /** @type {?} */
788
- var split = prop.split('.');
789
- /** @type {?} */
790
- var lastIndex = split.length - 1;
791
- split.reduce((/**
792
- * @param {?} acc
793
- * @param {?} part
794
- * @param {?} index
795
- * @return {?}
796
- */
797
- function (acc, part, index) {
798
- if (index === lastIndex) {
799
- acc[part] = val;
800
- }
801
- else {
802
- acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : __assign({}, acc[part]);
803
- }
804
- return acc && acc[part];
805
- }), obj);
806
- return obj;
807
- });
808
- /**
809
- * Get a deeply nested value. Example:
810
- *
811
- * getValue({ foo: bar: [] }, 'foo.bar') //=> []
812
- *
813
- * @ignore
814
- * @type {?}
815
- */
816
- var getValue = (/**
817
- * @param {?} obj
818
- * @param {?} prop
819
- * @return {?}
820
- */
821
- function (obj, prop) {
822
- return prop.split('.').reduce((/**
823
- * @param {?} acc
824
- * @param {?} part
825
- * @return {?}
826
- */
827
- function (acc, part) { return acc && acc[part]; }), obj);
828
- });
829
- /**
830
- * Simple object check.
831
- *
832
- * isObject({a:1}) //=> true
833
- * isObject(1) //=> false
834
- *
835
- * @ignore
836
- * @type {?}
837
- */
838
- var isObject = (/**
839
- * @param {?} item
840
- * @return {?}
841
- */
842
- function (item) {
843
- return item && typeof item === 'object' && !Array.isArray(item);
844
- });
845
- /**
846
- * Deep merge two objects.
847
- *
848
- * mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
849
- *
850
- * \@param base base object onto which `sources` will be applied
851
- * @type {?}
852
- */
853
- var mergeDeep = (/**
854
- * @param {?} base
855
- * @param {...?} sources
856
- * @return {?}
857
- */
858
- function (base) {
859
- var sources = [];
860
- for (var _i = 1; _i < arguments.length; _i++) {
861
- sources[_i - 1] = arguments[_i];
862
- }
863
- var _a, _b;
864
- if (!sources.length)
865
- return base;
866
- /** @type {?} */
867
- var source = sources.shift();
868
- if (isObject(base) && isObject(source)) {
869
- for (var key in source) {
870
- if (isObject(source[key])) {
871
- if (!base[key])
872
- Object.assign(base, (_a = {}, _a[key] = {}, _a));
873
- mergeDeep(base[key], source[key]);
874
- }
875
- else {
876
- Object.assign(base, (_b = {}, _b[key] = source[key], _b));
877
- }
878
- }
879
- }
880
- return mergeDeep.apply(void 0, __spread([base], sources));
881
- });
882
-
883
733
  /**
884
734
  * @fileoverview added by tsickle
885
735
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -1004,17 +854,6 @@
1004
854
  /** @type {?} */
1005
855
  StatesAndDefaults.prototype.states;
1006
856
  }
1007
- /**
1008
- * @record
1009
- * @template T
1010
- */
1011
- function RootStateDiff() { }
1012
- if (false) {
1013
- /** @type {?} */
1014
- RootStateDiff.prototype.currentAppState;
1015
- /** @type {?} */
1016
- RootStateDiff.prototype.newAppState;
1017
- }
1018
857
  /**
1019
858
  * Ensures metadata is attached to the class and returns it.
1020
859
  *
@@ -1356,22 +1195,159 @@
1356
1195
  * @param {?} obj
1357
1196
  * @return {?}
1358
1197
  */
1359
- function isObject$1(obj) {
1198
+ function isObject(obj) {
1360
1199
  return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
1361
1200
  }
1201
+
1362
1202
  /**
1363
- * @template T
1364
- * @param {?} mappedStore
1365
- * @param {?} diff
1203
+ * @fileoverview added by tsickle
1204
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1205
+ */
1206
+ /**
1207
+ * Returns the type from an action instance/class.
1208
+ * @ignore
1209
+ * @param {?} action
1210
+ * @return {?}
1211
+ */
1212
+ function getActionTypeFromInstance(action) {
1213
+ if (action.constructor && action.constructor.type) {
1214
+ return action.constructor.type;
1215
+ }
1216
+ else {
1217
+ return action.type;
1218
+ }
1219
+ }
1220
+ /**
1221
+ * Matches a action
1222
+ * @ignore
1223
+ * @param {?} action1
1224
+ * @return {?}
1225
+ */
1226
+ function actionMatcher(action1) {
1227
+ /** @type {?} */
1228
+ var type1 = getActionTypeFromInstance(action1);
1229
+ return (/**
1230
+ * @param {?} action2
1231
+ * @return {?}
1232
+ */
1233
+ function (action2) {
1234
+ return type1 === getActionTypeFromInstance(action2);
1235
+ });
1236
+ }
1237
+ /**
1238
+ * Set a deeply nested value. Example:
1239
+ *
1240
+ * setValue({ foo: { bar: { eat: false } } },
1241
+ * 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
1242
+ *
1243
+ * While it traverses it also creates new objects from top down.
1244
+ *
1245
+ * @ignore
1246
+ * @type {?}
1247
+ */
1248
+ var setValue = (/**
1249
+ * @param {?} obj
1250
+ * @param {?} prop
1251
+ * @param {?} val
1252
+ * @return {?}
1253
+ */
1254
+ function (obj, prop, val) {
1255
+ obj = __assign({}, obj);
1256
+ /** @type {?} */
1257
+ var split = prop.split('.');
1258
+ /** @type {?} */
1259
+ var lastIndex = split.length - 1;
1260
+ split.reduce((/**
1261
+ * @param {?} acc
1262
+ * @param {?} part
1263
+ * @param {?} index
1264
+ * @return {?}
1265
+ */
1266
+ function (acc, part, index) {
1267
+ if (index === lastIndex) {
1268
+ acc[part] = val;
1269
+ }
1270
+ else {
1271
+ acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : __assign({}, acc[part]);
1272
+ }
1273
+ return acc && acc[part];
1274
+ }), obj);
1275
+ return obj;
1276
+ });
1277
+ /**
1278
+ * Get a deeply nested value. Example:
1279
+ *
1280
+ * getValue({ foo: bar: [] }, 'foo.bar') //=> []
1281
+ *
1282
+ * @ignore
1283
+ * @type {?}
1284
+ */
1285
+ var getValue = (/**
1286
+ * @param {?} obj
1287
+ * @param {?} prop
1288
+ * @return {?}
1289
+ */
1290
+ function (obj, prop) {
1291
+ return prop.split('.').reduce((/**
1292
+ * @param {?} acc
1293
+ * @param {?} part
1294
+ * @return {?}
1295
+ */
1296
+ function (acc, part) { return acc && acc[part]; }), obj);
1297
+ });
1298
+ /**
1299
+ * Simple object check.
1300
+ *
1301
+ * isObject({a:1}) //=> true
1302
+ * isObject(1) //=> false
1303
+ *
1304
+ * @ignore
1305
+ * @type {?}
1306
+ */
1307
+ var isObject$1 = (/**
1308
+ * @param {?} item
1309
+ * @return {?}
1310
+ */
1311
+ function (item) {
1312
+ return item && typeof item === 'object' && !Array.isArray(item);
1313
+ });
1314
+ /**
1315
+ * Deep merge two objects.
1316
+ *
1317
+ * mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
1318
+ *
1319
+ * \@param base base object onto which `sources` will be applied
1320
+ * @type {?}
1321
+ */
1322
+ var mergeDeep = (/**
1323
+ * @param {?} base
1324
+ * @param {...?} sources
1366
1325
  * @return {?}
1367
1326
  */
1368
- function getStateDiffChanges(mappedStore, diff) {
1369
- /** @type {?} */
1370
- var previousValue = getValue(diff.currentAppState, mappedStore.path);
1327
+ function (base) {
1328
+ var sources = [];
1329
+ for (var _i = 1; _i < arguments.length; _i++) {
1330
+ sources[_i - 1] = arguments[_i];
1331
+ }
1332
+ var _a, _b;
1333
+ if (!sources.length)
1334
+ return base;
1371
1335
  /** @type {?} */
1372
- var currentValue = getValue(diff.newAppState, mappedStore.path);
1373
- return new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
1374
- }
1336
+ var source = sources.shift();
1337
+ if (isObject$1(base) && isObject$1(source)) {
1338
+ for (var key in source) {
1339
+ if (isObject$1(source[key])) {
1340
+ if (!base[key])
1341
+ Object.assign(base, (_a = {}, _a[key] = {}, _a));
1342
+ mergeDeep(base[key], source[key]);
1343
+ }
1344
+ else {
1345
+ Object.assign(base, (_b = {}, _b[key] = source[key], _b));
1346
+ }
1347
+ }
1348
+ }
1349
+ return mergeDeep.apply(void 0, __spread([base], sources));
1350
+ });
1375
1351
 
1376
1352
  /**
1377
1353
  * @fileoverview added by tsickle
@@ -1810,6 +1786,15 @@
1810
1786
  function InternalActions() {
1811
1787
  return _super !== null && _super.apply(this, arguments) || this;
1812
1788
  }
1789
+ /**
1790
+ * @return {?}
1791
+ */
1792
+ InternalActions.prototype.ngOnDestroy = /**
1793
+ * @return {?}
1794
+ */
1795
+ function () {
1796
+ this.complete();
1797
+ };
1813
1798
  InternalActions.decorators = [
1814
1799
  { type: core.Injectable }
1815
1800
  ];
@@ -2507,16 +2492,6 @@
2507
2492
  function setStateValue(currentAppState, newValue) {
2508
2493
  /** @type {?} */
2509
2494
  var newAppState = setValue(currentAppState, mappedStore.path, newValue);
2510
- /** @type {?} */
2511
- var instance = mappedStore.instance;
2512
- if (instance.ngxsOnChanges) {
2513
- /** @type {?} */
2514
- var change = getStateDiffChanges(mappedStore, {
2515
- currentAppState: currentAppState,
2516
- newAppState: newAppState
2517
- });
2518
- instance.ngxsOnChanges(change);
2519
- }
2520
2495
  root.setState(newAppState);
2521
2496
  return newAppState;
2522
2497
  // In doing this refactoring I noticed that there is a 'bug' where the
@@ -2830,7 +2805,7 @@
2830
2805
  if (Array.isArray(defaults)) {
2831
2806
  value = defaults.slice();
2832
2807
  }
2833
- else if (isObject$1(defaults)) {
2808
+ else if (isObject(defaults)) {
2834
2809
  value = __assign({}, defaults);
2835
2810
  }
2836
2811
  else if (defaults === undefined) {
@@ -3159,285 +3134,116 @@
3159
3134
  * @param {?} path
3160
3135
  * @return {?}
3161
3136
  */
3162
- function (meta, path) {
3163
- this.statePaths[(/** @type {?} */ (meta.name))] = path;
3164
- // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
3165
- // we can do this when we get rid of the incorrectly exposed getStoreMetadata
3166
- // We will need to come up with an alternative in v4 because this is used by many plugins
3167
- meta.path = path;
3168
- };
3169
- /**
3170
- * @description
3171
- * the method checks if the state has already been added to the tree
3172
- * and completed the life cycle
3173
- * @param name
3174
- * @param path
3175
- */
3176
- /**
3177
- * \@description
3178
- * the method checks if the state has already been added to the tree
3179
- * and completed the life cycle
3180
- * @private
3181
- * @param {?} name
3182
- * @param {?} path
3183
- * @return {?}
3184
- */
3185
- StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
3186
- * \@description
3187
- * the method checks if the state has already been added to the tree
3188
- * and completed the life cycle
3189
- * @private
3190
- * @param {?} name
3191
- * @param {?} path
3192
- * @return {?}
3193
- */
3194
- function (name, path) {
3195
- /** @type {?} */
3196
- var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
3197
- return this.statesByName[name] && valueIsBootstrappedInInitialState;
3198
- };
3199
- StateFactory.decorators = [
3200
- { type: core.Injectable }
3201
- ];
3202
- /** @nocollapse */
3203
- StateFactory.ctorParameters = function () { return [
3204
- { type: core.Injector },
3205
- { type: NgxsConfig },
3206
- { type: StateFactory, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
3207
- { type: InternalActions },
3208
- { type: InternalDispatchedActionResults },
3209
- { type: StateContextFactory },
3210
- { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [internals.INITIAL_STATE_TOKEN,] }] }
3211
- ]; };
3212
- return StateFactory;
3213
- }());
3214
- if (false) {
3215
- /**
3216
- * @type {?}
3217
- * @private
3218
- */
3219
- StateFactory.prototype._actionsSubscription;
3220
- /**
3221
- * @type {?}
3222
- * @private
3223
- */
3224
- StateFactory.prototype._states;
3225
- /**
3226
- * @type {?}
3227
- * @private
3228
- */
3229
- StateFactory.prototype._statesByName;
3230
- /**
3231
- * @type {?}
3232
- * @private
3233
- */
3234
- StateFactory.prototype._statePaths;
3235
- /** @type {?} */
3236
- StateFactory.prototype.getRuntimeSelectorContext;
3237
- /**
3238
- * @type {?}
3239
- * @private
3240
- */
3241
- StateFactory.prototype._injector;
3242
- /**
3243
- * @type {?}
3244
- * @private
3245
- */
3246
- StateFactory.prototype._config;
3247
- /**
3248
- * @type {?}
3249
- * @private
3250
- */
3251
- StateFactory.prototype._parentFactory;
3252
- /**
3253
- * @type {?}
3254
- * @private
3255
- */
3256
- StateFactory.prototype._actions;
3257
- /**
3258
- * @type {?}
3259
- * @private
3260
- */
3261
- StateFactory.prototype._actionResults;
3262
- /**
3263
- * @type {?}
3264
- * @private
3265
- */
3266
- StateFactory.prototype._stateContextFactory;
3267
- /**
3268
- * @type {?}
3269
- * @private
3270
- */
3271
- StateFactory.prototype._initialState;
3272
- }
3273
-
3274
- /**
3275
- * @fileoverview added by tsickle
3276
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3277
- */
3278
- var LifecycleStateManager = /** @class */ (function () {
3279
- function LifecycleStateManager(internalStateOperations, stateContextFactory, bootstrapper) {
3280
- this.internalStateOperations = internalStateOperations;
3281
- this.stateContextFactory = stateContextFactory;
3282
- this.bootstrapper = bootstrapper;
3283
- }
3284
- /**
3285
- * @template T
3286
- * @param {?} action
3287
- * @param {?} results
3288
- * @return {?}
3289
- */
3290
- LifecycleStateManager.prototype.ngxsBootstrap = /**
3291
- * @template T
3292
- * @param {?} action
3293
- * @param {?} results
3294
- * @return {?}
3295
- */
3296
- function (action, results) {
3297
- var _this = this;
3298
- this.internalStateOperations
3299
- .getRootStateOperations()
3300
- .dispatch(action)
3301
- .pipe(operators.filter((/**
3302
- * @return {?}
3303
- */
3304
- function () { return !!results; })), operators.tap((/**
3305
- * @return {?}
3306
- */
3307
- function () { return _this.invokeInit((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
3308
- * @return {?}
3309
- */
3310
- function () { return _this.bootstrapper.appBootstrapped$; })), operators.filter((/**
3311
- * @param {?} appBootstrapped
3312
- * @return {?}
3313
- */
3314
- function (appBootstrapped) { return !!appBootstrapped; })))
3315
- .subscribe((/**
3316
- * @return {?}
3317
- */
3318
- function () { return _this.invokeBootstrap((/** @type {?} */ (results)).states); }));
3319
- };
3320
- /**
3321
- * Invoke the init function on the states.
3322
- */
3323
- /**
3324
- * Invoke the init function on the states.
3325
- * @param {?} mappedStores
3326
- * @return {?}
3327
- */
3328
- LifecycleStateManager.prototype.invokeInit = /**
3329
- * Invoke the init function on the states.
3330
- * @param {?} mappedStores
3331
- * @return {?}
3332
- */
3333
- function (mappedStores) {
3334
- var e_1, _a;
3335
- try {
3336
- for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3337
- var mappedStore = mappedStores_1_1.value;
3338
- /** @type {?} */
3339
- var instance = mappedStore.instance;
3340
- if (instance.ngxsOnChanges) {
3341
- /** @type {?} */
3342
- var currentAppState = {};
3343
- /** @type {?} */
3344
- var newAppState = this.internalStateOperations
3345
- .getRootStateOperations()
3346
- .getState();
3347
- /** @type {?} */
3348
- var firstDiffChange = getStateDiffChanges(mappedStore, {
3349
- currentAppState: currentAppState,
3350
- newAppState: newAppState
3351
- });
3352
- instance.ngxsOnChanges(firstDiffChange);
3353
- }
3354
- if (instance.ngxsOnInit) {
3355
- instance.ngxsOnInit(this.getStateContext(mappedStore));
3356
- }
3357
- mappedStore.isInitialised = true;
3358
- }
3359
- }
3360
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3361
- finally {
3362
- try {
3363
- if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3364
- }
3365
- finally { if (e_1) throw e_1.error; }
3366
- }
3367
- };
3368
- /**
3369
- * Invoke the bootstrap function on the states.
3370
- */
3371
- /**
3372
- * Invoke the bootstrap function on the states.
3373
- * @param {?} mappedStores
3374
- * @return {?}
3375
- */
3376
- LifecycleStateManager.prototype.invokeBootstrap = /**
3377
- * Invoke the bootstrap function on the states.
3378
- * @param {?} mappedStores
3379
- * @return {?}
3380
- */
3381
- function (mappedStores) {
3382
- var e_2, _a;
3383
- try {
3384
- for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3385
- var mappedStore = mappedStores_2_1.value;
3386
- /** @type {?} */
3387
- var instance = mappedStore.instance;
3388
- if (instance.ngxsAfterBootstrap) {
3389
- instance.ngxsAfterBootstrap(this.getStateContext(mappedStore));
3390
- }
3391
- }
3392
- }
3393
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3394
- finally {
3395
- try {
3396
- if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3397
- }
3398
- finally { if (e_2) throw e_2.error; }
3399
- }
3137
+ function (meta, path) {
3138
+ this.statePaths[(/** @type {?} */ (meta.name))] = path;
3139
+ // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
3140
+ // we can do this when we get rid of the incorrectly exposed getStoreMetadata
3141
+ // We will need to come up with an alternative in v4 because this is used by many plugins
3142
+ meta.path = path;
3400
3143
  };
3401
3144
  /**
3145
+ * @description
3146
+ * the method checks if the state has already been added to the tree
3147
+ * and completed the life cycle
3148
+ * @param name
3149
+ * @param path
3150
+ */
3151
+ /**
3152
+ * \@description
3153
+ * the method checks if the state has already been added to the tree
3154
+ * and completed the life cycle
3402
3155
  * @private
3403
- * @param {?} mappedStore
3156
+ * @param {?} name
3157
+ * @param {?} path
3404
3158
  * @return {?}
3405
3159
  */
3406
- LifecycleStateManager.prototype.getStateContext = /**
3160
+ StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
3161
+ * \@description
3162
+ * the method checks if the state has already been added to the tree
3163
+ * and completed the life cycle
3407
3164
  * @private
3408
- * @param {?} mappedStore
3165
+ * @param {?} name
3166
+ * @param {?} path
3409
3167
  * @return {?}
3410
3168
  */
3411
- function (mappedStore) {
3412
- return this.stateContextFactory.createStateContext(mappedStore);
3169
+ function (name, path) {
3170
+ /** @type {?} */
3171
+ var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
3172
+ return this.statesByName[name] && valueIsBootstrappedInInitialState;
3413
3173
  };
3414
- LifecycleStateManager.decorators = [
3174
+ StateFactory.decorators = [
3415
3175
  { type: core.Injectable }
3416
3176
  ];
3417
3177
  /** @nocollapse */
3418
- LifecycleStateManager.ctorParameters = function () { return [
3419
- { type: InternalStateOperations },
3178
+ StateFactory.ctorParameters = function () { return [
3179
+ { type: core.Injector },
3180
+ { type: NgxsConfig },
3181
+ { type: StateFactory, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
3182
+ { type: InternalActions },
3183
+ { type: InternalDispatchedActionResults },
3420
3184
  { type: StateContextFactory },
3421
- { type: internals.NgxsBootstrapper }
3185
+ { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [internals.INITIAL_STATE_TOKEN,] }] }
3422
3186
  ]; };
3423
- return LifecycleStateManager;
3187
+ return StateFactory;
3424
3188
  }());
3425
3189
  if (false) {
3426
3190
  /**
3427
3191
  * @type {?}
3428
3192
  * @private
3429
3193
  */
3430
- LifecycleStateManager.prototype.internalStateOperations;
3194
+ StateFactory.prototype._actionsSubscription;
3195
+ /**
3196
+ * @type {?}
3197
+ * @private
3198
+ */
3199
+ StateFactory.prototype._states;
3200
+ /**
3201
+ * @type {?}
3202
+ * @private
3203
+ */
3204
+ StateFactory.prototype._statesByName;
3205
+ /**
3206
+ * @type {?}
3207
+ * @private
3208
+ */
3209
+ StateFactory.prototype._statePaths;
3210
+ /** @type {?} */
3211
+ StateFactory.prototype.getRuntimeSelectorContext;
3212
+ /**
3213
+ * @type {?}
3214
+ * @private
3215
+ */
3216
+ StateFactory.prototype._injector;
3217
+ /**
3218
+ * @type {?}
3219
+ * @private
3220
+ */
3221
+ StateFactory.prototype._config;
3222
+ /**
3223
+ * @type {?}
3224
+ * @private
3225
+ */
3226
+ StateFactory.prototype._parentFactory;
3227
+ /**
3228
+ * @type {?}
3229
+ * @private
3230
+ */
3231
+ StateFactory.prototype._actions;
3232
+ /**
3233
+ * @type {?}
3234
+ * @private
3235
+ */
3236
+ StateFactory.prototype._actionResults;
3431
3237
  /**
3432
3238
  * @type {?}
3433
3239
  * @private
3434
3240
  */
3435
- LifecycleStateManager.prototype.stateContextFactory;
3241
+ StateFactory.prototype._stateContextFactory;
3436
3242
  /**
3437
3243
  * @type {?}
3438
3244
  * @private
3439
3245
  */
3440
- LifecycleStateManager.prototype.bootstrapper;
3246
+ StateFactory.prototype._initialState;
3441
3247
  }
3442
3248
 
3443
3249
  /**
@@ -3894,6 +3700,210 @@
3894
3700
  Store.prototype._stateFactory;
3895
3701
  }
3896
3702
 
3703
+ /**
3704
+ * @fileoverview added by tsickle
3705
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3706
+ */
3707
+ var LifecycleStateManager = /** @class */ (function () {
3708
+ function LifecycleStateManager(_store, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3709
+ this._store = _store;
3710
+ this._internalStateOperations = _internalStateOperations;
3711
+ this._stateContextFactory = _stateContextFactory;
3712
+ this._bootstrapper = _bootstrapper;
3713
+ this._destroy$ = new rxjs.Subject();
3714
+ }
3715
+ /**
3716
+ * @return {?}
3717
+ */
3718
+ LifecycleStateManager.prototype.ngOnDestroy = /**
3719
+ * @return {?}
3720
+ */
3721
+ function () {
3722
+ this._destroy$.next();
3723
+ };
3724
+ /**
3725
+ * @template T
3726
+ * @param {?} action
3727
+ * @param {?} results
3728
+ * @return {?}
3729
+ */
3730
+ LifecycleStateManager.prototype.ngxsBootstrap = /**
3731
+ * @template T
3732
+ * @param {?} action
3733
+ * @param {?} results
3734
+ * @return {?}
3735
+ */
3736
+ function (action, results) {
3737
+ var _this = this;
3738
+ this._internalStateOperations
3739
+ .getRootStateOperations()
3740
+ .dispatch(action)
3741
+ .pipe(operators.filter((/**
3742
+ * @return {?}
3743
+ */
3744
+ function () { return !!results; })), operators.tap((/**
3745
+ * @return {?}
3746
+ */
3747
+ function () { return _this._invokeInit((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
3748
+ * @return {?}
3749
+ */
3750
+ function () { return _this._bootstrapper.appBootstrapped$; })), operators.filter((/**
3751
+ * @param {?} appBootstrapped
3752
+ * @return {?}
3753
+ */
3754
+ function (appBootstrapped) { return !!appBootstrapped; })), operators.takeUntil(this._destroy$))
3755
+ .subscribe((/**
3756
+ * @return {?}
3757
+ */
3758
+ function () { return _this._invokeBootstrap((/** @type {?} */ (results)).states); }));
3759
+ };
3760
+ /**
3761
+ * Invoke the init function on the states.
3762
+ */
3763
+ /**
3764
+ * Invoke the init function on the states.
3765
+ * @private
3766
+ * @param {?} mappedStores
3767
+ * @return {?}
3768
+ */
3769
+ LifecycleStateManager.prototype._invokeInit = /**
3770
+ * Invoke the init function on the states.
3771
+ * @private
3772
+ * @param {?} mappedStores
3773
+ * @return {?}
3774
+ */
3775
+ function (mappedStores) {
3776
+ var e_1, _a;
3777
+ var _loop_1 = function (mappedStore) {
3778
+ /** @type {?} */
3779
+ var instance = mappedStore.instance;
3780
+ if (instance.ngxsOnChanges) {
3781
+ this_1._store
3782
+ .select((/**
3783
+ * @param {?} state
3784
+ * @return {?}
3785
+ */
3786
+ function (state) { return getValue(state, mappedStore.path); }))
3787
+ .pipe(operators.startWith(undefined), operators.pairwise(), operators.takeUntil(this_1._destroy$))
3788
+ .subscribe((/**
3789
+ * @param {?} __0
3790
+ * @return {?}
3791
+ */
3792
+ function (_a) {
3793
+ var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
3794
+ /** @type {?} */
3795
+ var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
3796
+ (/** @type {?} */ (instance.ngxsOnChanges))(change);
3797
+ }));
3798
+ }
3799
+ if (instance.ngxsOnInit) {
3800
+ instance.ngxsOnInit(this_1._getStateContext(mappedStore));
3801
+ }
3802
+ mappedStore.isInitialised = true;
3803
+ };
3804
+ var this_1 = this;
3805
+ try {
3806
+ for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3807
+ var mappedStore = mappedStores_1_1.value;
3808
+ _loop_1(mappedStore);
3809
+ }
3810
+ }
3811
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3812
+ finally {
3813
+ try {
3814
+ if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3815
+ }
3816
+ finally { if (e_1) throw e_1.error; }
3817
+ }
3818
+ };
3819
+ /**
3820
+ * Invoke the bootstrap function on the states.
3821
+ */
3822
+ /**
3823
+ * Invoke the bootstrap function on the states.
3824
+ * @private
3825
+ * @param {?} mappedStores
3826
+ * @return {?}
3827
+ */
3828
+ LifecycleStateManager.prototype._invokeBootstrap = /**
3829
+ * Invoke the bootstrap function on the states.
3830
+ * @private
3831
+ * @param {?} mappedStores
3832
+ * @return {?}
3833
+ */
3834
+ function (mappedStores) {
3835
+ var e_2, _a;
3836
+ try {
3837
+ for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3838
+ var mappedStore = mappedStores_2_1.value;
3839
+ /** @type {?} */
3840
+ var instance = mappedStore.instance;
3841
+ if (instance.ngxsAfterBootstrap) {
3842
+ instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
3843
+ }
3844
+ }
3845
+ }
3846
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3847
+ finally {
3848
+ try {
3849
+ if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3850
+ }
3851
+ finally { if (e_2) throw e_2.error; }
3852
+ }
3853
+ };
3854
+ /**
3855
+ * @private
3856
+ * @param {?} mappedStore
3857
+ * @return {?}
3858
+ */
3859
+ LifecycleStateManager.prototype._getStateContext = /**
3860
+ * @private
3861
+ * @param {?} mappedStore
3862
+ * @return {?}
3863
+ */
3864
+ function (mappedStore) {
3865
+ return this._stateContextFactory.createStateContext(mappedStore);
3866
+ };
3867
+ LifecycleStateManager.decorators = [
3868
+ { type: core.Injectable }
3869
+ ];
3870
+ /** @nocollapse */
3871
+ LifecycleStateManager.ctorParameters = function () { return [
3872
+ { type: Store },
3873
+ { type: InternalStateOperations },
3874
+ { type: StateContextFactory },
3875
+ { type: internals.NgxsBootstrapper }
3876
+ ]; };
3877
+ return LifecycleStateManager;
3878
+ }());
3879
+ if (false) {
3880
+ /**
3881
+ * @type {?}
3882
+ * @private
3883
+ */
3884
+ LifecycleStateManager.prototype._destroy$;
3885
+ /**
3886
+ * @type {?}
3887
+ * @private
3888
+ */
3889
+ LifecycleStateManager.prototype._store;
3890
+ /**
3891
+ * @type {?}
3892
+ * @private
3893
+ */
3894
+ LifecycleStateManager.prototype._internalStateOperations;
3895
+ /**
3896
+ * @type {?}
3897
+ * @private
3898
+ */
3899
+ LifecycleStateManager.prototype._stateContextFactory;
3900
+ /**
3901
+ * @type {?}
3902
+ * @private
3903
+ */
3904
+ LifecycleStateManager.prototype._bootstrapper;
3905
+ }
3906
+
3897
3907
  /**
3898
3908
  * @fileoverview added by tsickle
3899
3909
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc