@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.
@@ -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
  *
@@ -1352,26 +1191,163 @@
1352
1191
  /**
1353
1192
  * Returns if the parameter is a object or not.
1354
1193
  *
1355
- * @ignore
1356
- * @param {?} obj
1357
- * @return {?}
1194
+ * @ignore
1195
+ * @param {?} obj
1196
+ * @return {?}
1197
+ */
1198
+ function isObject(obj) {
1199
+ return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
1200
+ }
1201
+
1202
+ /**
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 {?}
1358
1321
  */
1359
- function isObject$1(obj) {
1360
- return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
1361
- }
1362
- /**
1363
- * @template T
1364
- * @param {?} mappedStore
1365
- * @param {?} diff
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
@@ -2507,16 +2483,6 @@
2507
2483
  function setStateValue(currentAppState, newValue) {
2508
2484
  /** @type {?} */
2509
2485
  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
2486
  root.setState(newAppState);
2521
2487
  return newAppState;
2522
2488
  // In doing this refactoring I noticed that there is a 'bug' where the
@@ -2830,7 +2796,7 @@
2830
2796
  if (Array.isArray(defaults)) {
2831
2797
  value = defaults.slice();
2832
2798
  }
2833
- else if (isObject$1(defaults)) {
2799
+ else if (isObject(defaults)) {
2834
2800
  value = __assign({}, defaults);
2835
2801
  }
2836
2802
  else if (defaults === undefined) {
@@ -3159,285 +3125,116 @@
3159
3125
  * @param {?} path
3160
3126
  * @return {?}
3161
3127
  */
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
- }
3128
+ function (meta, path) {
3129
+ this.statePaths[(/** @type {?} */ (meta.name))] = path;
3130
+ // TODO: v4 - we plan to get rid of the path property because it is non-deterministic
3131
+ // we can do this when we get rid of the incorrectly exposed getStoreMetadata
3132
+ // We will need to come up with an alternative in v4 because this is used by many plugins
3133
+ meta.path = path;
3400
3134
  };
3401
3135
  /**
3136
+ * @description
3137
+ * the method checks if the state has already been added to the tree
3138
+ * and completed the life cycle
3139
+ * @param name
3140
+ * @param path
3141
+ */
3142
+ /**
3143
+ * \@description
3144
+ * the method checks if the state has already been added to the tree
3145
+ * and completed the life cycle
3402
3146
  * @private
3403
- * @param {?} mappedStore
3147
+ * @param {?} name
3148
+ * @param {?} path
3404
3149
  * @return {?}
3405
3150
  */
3406
- LifecycleStateManager.prototype.getStateContext = /**
3151
+ StateFactory.prototype.hasBeenMountedAndBootstrapped = /**
3152
+ * \@description
3153
+ * the method checks if the state has already been added to the tree
3154
+ * and completed the life cycle
3407
3155
  * @private
3408
- * @param {?} mappedStore
3156
+ * @param {?} name
3157
+ * @param {?} path
3409
3158
  * @return {?}
3410
3159
  */
3411
- function (mappedStore) {
3412
- return this.stateContextFactory.createStateContext(mappedStore);
3160
+ function (name, path) {
3161
+ /** @type {?} */
3162
+ var valueIsBootstrappedInInitialState = getValue(this._initialState, path) !== undefined;
3163
+ return this.statesByName[name] && valueIsBootstrappedInInitialState;
3413
3164
  };
3414
- LifecycleStateManager.decorators = [
3165
+ StateFactory.decorators = [
3415
3166
  { type: core.Injectable }
3416
3167
  ];
3417
3168
  /** @nocollapse */
3418
- LifecycleStateManager.ctorParameters = function () { return [
3419
- { type: InternalStateOperations },
3169
+ StateFactory.ctorParameters = function () { return [
3170
+ { type: core.Injector },
3171
+ { type: NgxsConfig },
3172
+ { type: StateFactory, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
3173
+ { type: InternalActions },
3174
+ { type: InternalDispatchedActionResults },
3420
3175
  { type: StateContextFactory },
3421
- { type: internals.NgxsBootstrapper }
3176
+ { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [internals.INITIAL_STATE_TOKEN,] }] }
3422
3177
  ]; };
3423
- return LifecycleStateManager;
3178
+ return StateFactory;
3424
3179
  }());
3425
3180
  if (false) {
3426
3181
  /**
3427
3182
  * @type {?}
3428
3183
  * @private
3429
3184
  */
3430
- LifecycleStateManager.prototype.internalStateOperations;
3185
+ StateFactory.prototype._actionsSubscription;
3186
+ /**
3187
+ * @type {?}
3188
+ * @private
3189
+ */
3190
+ StateFactory.prototype._states;
3191
+ /**
3192
+ * @type {?}
3193
+ * @private
3194
+ */
3195
+ StateFactory.prototype._statesByName;
3196
+ /**
3197
+ * @type {?}
3198
+ * @private
3199
+ */
3200
+ StateFactory.prototype._statePaths;
3201
+ /** @type {?} */
3202
+ StateFactory.prototype.getRuntimeSelectorContext;
3203
+ /**
3204
+ * @type {?}
3205
+ * @private
3206
+ */
3207
+ StateFactory.prototype._injector;
3208
+ /**
3209
+ * @type {?}
3210
+ * @private
3211
+ */
3212
+ StateFactory.prototype._config;
3213
+ /**
3214
+ * @type {?}
3215
+ * @private
3216
+ */
3217
+ StateFactory.prototype._parentFactory;
3218
+ /**
3219
+ * @type {?}
3220
+ * @private
3221
+ */
3222
+ StateFactory.prototype._actions;
3223
+ /**
3224
+ * @type {?}
3225
+ * @private
3226
+ */
3227
+ StateFactory.prototype._actionResults;
3431
3228
  /**
3432
3229
  * @type {?}
3433
3230
  * @private
3434
3231
  */
3435
- LifecycleStateManager.prototype.stateContextFactory;
3232
+ StateFactory.prototype._stateContextFactory;
3436
3233
  /**
3437
3234
  * @type {?}
3438
3235
  * @private
3439
3236
  */
3440
- LifecycleStateManager.prototype.bootstrapper;
3237
+ StateFactory.prototype._initialState;
3441
3238
  }
3442
3239
 
3443
3240
  /**
@@ -3894,6 +3691,210 @@
3894
3691
  Store.prototype._stateFactory;
3895
3692
  }
3896
3693
 
3694
+ /**
3695
+ * @fileoverview added by tsickle
3696
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
3697
+ */
3698
+ var LifecycleStateManager = /** @class */ (function () {
3699
+ function LifecycleStateManager(_store, _internalStateOperations, _stateContextFactory, _bootstrapper) {
3700
+ this._store = _store;
3701
+ this._internalStateOperations = _internalStateOperations;
3702
+ this._stateContextFactory = _stateContextFactory;
3703
+ this._bootstrapper = _bootstrapper;
3704
+ this._destroy$ = new rxjs.Subject();
3705
+ }
3706
+ /**
3707
+ * @return {?}
3708
+ */
3709
+ LifecycleStateManager.prototype.ngOnDestroy = /**
3710
+ * @return {?}
3711
+ */
3712
+ function () {
3713
+ this._destroy$.next();
3714
+ };
3715
+ /**
3716
+ * @template T
3717
+ * @param {?} action
3718
+ * @param {?} results
3719
+ * @return {?}
3720
+ */
3721
+ LifecycleStateManager.prototype.ngxsBootstrap = /**
3722
+ * @template T
3723
+ * @param {?} action
3724
+ * @param {?} results
3725
+ * @return {?}
3726
+ */
3727
+ function (action, results) {
3728
+ var _this = this;
3729
+ this._internalStateOperations
3730
+ .getRootStateOperations()
3731
+ .dispatch(action)
3732
+ .pipe(operators.filter((/**
3733
+ * @return {?}
3734
+ */
3735
+ function () { return !!results; })), operators.tap((/**
3736
+ * @return {?}
3737
+ */
3738
+ function () { return _this._invokeInit((/** @type {?} */ (results)).states); })), operators.mergeMap((/**
3739
+ * @return {?}
3740
+ */
3741
+ function () { return _this._bootstrapper.appBootstrapped$; })), operators.filter((/**
3742
+ * @param {?} appBootstrapped
3743
+ * @return {?}
3744
+ */
3745
+ function (appBootstrapped) { return !!appBootstrapped; })), operators.takeUntil(this._destroy$))
3746
+ .subscribe((/**
3747
+ * @return {?}
3748
+ */
3749
+ function () { return _this._invokeBootstrap((/** @type {?} */ (results)).states); }));
3750
+ };
3751
+ /**
3752
+ * Invoke the init function on the states.
3753
+ */
3754
+ /**
3755
+ * Invoke the init function on the states.
3756
+ * @private
3757
+ * @param {?} mappedStores
3758
+ * @return {?}
3759
+ */
3760
+ LifecycleStateManager.prototype._invokeInit = /**
3761
+ * Invoke the init function on the states.
3762
+ * @private
3763
+ * @param {?} mappedStores
3764
+ * @return {?}
3765
+ */
3766
+ function (mappedStores) {
3767
+ var e_1, _a;
3768
+ var _loop_1 = function (mappedStore) {
3769
+ /** @type {?} */
3770
+ var instance = mappedStore.instance;
3771
+ if (instance.ngxsOnChanges) {
3772
+ this_1._store
3773
+ .select((/**
3774
+ * @param {?} state
3775
+ * @return {?}
3776
+ */
3777
+ function (state) { return getValue(state, mappedStore.path); }))
3778
+ .pipe(operators.startWith(undefined), operators.pairwise(), operators.takeUntil(this_1._destroy$))
3779
+ .subscribe((/**
3780
+ * @param {?} __0
3781
+ * @return {?}
3782
+ */
3783
+ function (_a) {
3784
+ var _b = __read(_a, 2), previousValue = _b[0], currentValue = _b[1];
3785
+ /** @type {?} */
3786
+ var change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
3787
+ (/** @type {?} */ (instance.ngxsOnChanges))(change);
3788
+ }));
3789
+ }
3790
+ if (instance.ngxsOnInit) {
3791
+ instance.ngxsOnInit(this_1._getStateContext(mappedStore));
3792
+ }
3793
+ mappedStore.isInitialised = true;
3794
+ };
3795
+ var this_1 = this;
3796
+ try {
3797
+ for (var mappedStores_1 = __values(mappedStores), mappedStores_1_1 = mappedStores_1.next(); !mappedStores_1_1.done; mappedStores_1_1 = mappedStores_1.next()) {
3798
+ var mappedStore = mappedStores_1_1.value;
3799
+ _loop_1(mappedStore);
3800
+ }
3801
+ }
3802
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3803
+ finally {
3804
+ try {
3805
+ if (mappedStores_1_1 && !mappedStores_1_1.done && (_a = mappedStores_1.return)) _a.call(mappedStores_1);
3806
+ }
3807
+ finally { if (e_1) throw e_1.error; }
3808
+ }
3809
+ };
3810
+ /**
3811
+ * Invoke the bootstrap function on the states.
3812
+ */
3813
+ /**
3814
+ * Invoke the bootstrap function on the states.
3815
+ * @private
3816
+ * @param {?} mappedStores
3817
+ * @return {?}
3818
+ */
3819
+ LifecycleStateManager.prototype._invokeBootstrap = /**
3820
+ * Invoke the bootstrap function on the states.
3821
+ * @private
3822
+ * @param {?} mappedStores
3823
+ * @return {?}
3824
+ */
3825
+ function (mappedStores) {
3826
+ var e_2, _a;
3827
+ try {
3828
+ for (var mappedStores_2 = __values(mappedStores), mappedStores_2_1 = mappedStores_2.next(); !mappedStores_2_1.done; mappedStores_2_1 = mappedStores_2.next()) {
3829
+ var mappedStore = mappedStores_2_1.value;
3830
+ /** @type {?} */
3831
+ var instance = mappedStore.instance;
3832
+ if (instance.ngxsAfterBootstrap) {
3833
+ instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
3834
+ }
3835
+ }
3836
+ }
3837
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
3838
+ finally {
3839
+ try {
3840
+ if (mappedStores_2_1 && !mappedStores_2_1.done && (_a = mappedStores_2.return)) _a.call(mappedStores_2);
3841
+ }
3842
+ finally { if (e_2) throw e_2.error; }
3843
+ }
3844
+ };
3845
+ /**
3846
+ * @private
3847
+ * @param {?} mappedStore
3848
+ * @return {?}
3849
+ */
3850
+ LifecycleStateManager.prototype._getStateContext = /**
3851
+ * @private
3852
+ * @param {?} mappedStore
3853
+ * @return {?}
3854
+ */
3855
+ function (mappedStore) {
3856
+ return this._stateContextFactory.createStateContext(mappedStore);
3857
+ };
3858
+ LifecycleStateManager.decorators = [
3859
+ { type: core.Injectable }
3860
+ ];
3861
+ /** @nocollapse */
3862
+ LifecycleStateManager.ctorParameters = function () { return [
3863
+ { type: Store },
3864
+ { type: InternalStateOperations },
3865
+ { type: StateContextFactory },
3866
+ { type: internals.NgxsBootstrapper }
3867
+ ]; };
3868
+ return LifecycleStateManager;
3869
+ }());
3870
+ if (false) {
3871
+ /**
3872
+ * @type {?}
3873
+ * @private
3874
+ */
3875
+ LifecycleStateManager.prototype._destroy$;
3876
+ /**
3877
+ * @type {?}
3878
+ * @private
3879
+ */
3880
+ LifecycleStateManager.prototype._store;
3881
+ /**
3882
+ * @type {?}
3883
+ * @private
3884
+ */
3885
+ LifecycleStateManager.prototype._internalStateOperations;
3886
+ /**
3887
+ * @type {?}
3888
+ * @private
3889
+ */
3890
+ LifecycleStateManager.prototype._stateContextFactory;
3891
+ /**
3892
+ * @type {?}
3893
+ * @private
3894
+ */
3895
+ LifecycleStateManager.prototype._bootstrapper;
3896
+ }
3897
+
3897
3898
  /**
3898
3899
  * @fileoverview added by tsickle
3899
3900
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc