@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.
- package/bundles/ngxs-store.umd.js +440 -439
- package/bundles/ngxs-store.umd.js.map +1 -1
- package/bundles/ngxs-store.umd.min.js +1 -1
- package/bundles/ngxs-store.umd.min.js.map +1 -1
- package/esm2015/src/internal/internals.js +2 -27
- package/esm2015/src/internal/lifecycle-state-manager.js +65 -36
- package/esm2015/src/internal/state-context-factory.js +1 -12
- package/esm5/src/internal/internals.js +2 -27
- package/esm5/src/internal/lifecycle-state-manager.js +78 -40
- package/esm5/src/internal/state-context-factory.js +1 -12
- package/fesm2015/ngxs-store.js +290 -298
- package/fesm2015/ngxs-store.js.map +1 -1
- package/fesm5/ngxs-store.js +442 -441
- package/fesm5/ngxs-store.js.map +1 -1
- package/ngxs-store.metadata.json +1 -1
- package/package.json +1 -1
- package/src/internal/internals.d.ts +1 -6
- package/src/internal/lifecycle-state-manager.d.ts +14 -9
package/fesm2015/ngxs-store.js
CHANGED
|
@@ -2,7 +2,7 @@ import { NgZone, Injectable, Inject, PLATFORM_ID, defineInjectable, inject, Inje
|
|
|
2
2
|
import { memoize, INITIAL_STATE_TOKEN, NgxsBootstrapper, NGXS_STATE_CONTEXT_FACTORY, NGXS_STATE_FACTORY, InitialState } from '@ngxs/store/internals';
|
|
3
3
|
import { isPlatformServer } from '@angular/common';
|
|
4
4
|
import { Observable, Subject, BehaviorSubject, of, forkJoin, throwError, EMPTY, from, isObservable, queueScheduler } from 'rxjs';
|
|
5
|
-
import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, tap,
|
|
5
|
+
import { filter, map, shareReplay, take, exhaustMap, mergeMap, defaultIfEmpty, catchError, takeUntil, observeOn, distinctUntilChanged, tap, startWith, pairwise } from 'rxjs/operators';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @fileoverview added by tsickle
|
|
@@ -477,149 +477,6 @@ if (false) {
|
|
|
477
477
|
NgxsExecutionStrategy.prototype.leave = function (func) { };
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
-
/**
|
|
481
|
-
* @fileoverview added by tsickle
|
|
482
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
483
|
-
*/
|
|
484
|
-
/**
|
|
485
|
-
* Returns the type from an action instance/class.
|
|
486
|
-
* @ignore
|
|
487
|
-
* @param {?} action
|
|
488
|
-
* @return {?}
|
|
489
|
-
*/
|
|
490
|
-
function getActionTypeFromInstance(action) {
|
|
491
|
-
if (action.constructor && action.constructor.type) {
|
|
492
|
-
return action.constructor.type;
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
return action.type;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Matches a action
|
|
500
|
-
* @ignore
|
|
501
|
-
* @param {?} action1
|
|
502
|
-
* @return {?}
|
|
503
|
-
*/
|
|
504
|
-
function actionMatcher(action1) {
|
|
505
|
-
/** @type {?} */
|
|
506
|
-
const type1 = getActionTypeFromInstance(action1);
|
|
507
|
-
return (/**
|
|
508
|
-
* @param {?} action2
|
|
509
|
-
* @return {?}
|
|
510
|
-
*/
|
|
511
|
-
function (action2) {
|
|
512
|
-
return type1 === getActionTypeFromInstance(action2);
|
|
513
|
-
});
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Set a deeply nested value. Example:
|
|
517
|
-
*
|
|
518
|
-
* setValue({ foo: { bar: { eat: false } } },
|
|
519
|
-
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
520
|
-
*
|
|
521
|
-
* While it traverses it also creates new objects from top down.
|
|
522
|
-
*
|
|
523
|
-
* @ignore
|
|
524
|
-
* @type {?}
|
|
525
|
-
*/
|
|
526
|
-
const setValue = (/**
|
|
527
|
-
* @param {?} obj
|
|
528
|
-
* @param {?} prop
|
|
529
|
-
* @param {?} val
|
|
530
|
-
* @return {?}
|
|
531
|
-
*/
|
|
532
|
-
(obj, prop, val) => {
|
|
533
|
-
obj = Object.assign({}, obj);
|
|
534
|
-
/** @type {?} */
|
|
535
|
-
const split = prop.split('.');
|
|
536
|
-
/** @type {?} */
|
|
537
|
-
const lastIndex = split.length - 1;
|
|
538
|
-
split.reduce((/**
|
|
539
|
-
* @param {?} acc
|
|
540
|
-
* @param {?} part
|
|
541
|
-
* @param {?} index
|
|
542
|
-
* @return {?}
|
|
543
|
-
*/
|
|
544
|
-
(acc, part, index) => {
|
|
545
|
-
if (index === lastIndex) {
|
|
546
|
-
acc[part] = val;
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
|
|
550
|
-
}
|
|
551
|
-
return acc && acc[part];
|
|
552
|
-
}), obj);
|
|
553
|
-
return obj;
|
|
554
|
-
});
|
|
555
|
-
/**
|
|
556
|
-
* Get a deeply nested value. Example:
|
|
557
|
-
*
|
|
558
|
-
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
559
|
-
*
|
|
560
|
-
* @ignore
|
|
561
|
-
* @type {?}
|
|
562
|
-
*/
|
|
563
|
-
const getValue = (/**
|
|
564
|
-
* @param {?} obj
|
|
565
|
-
* @param {?} prop
|
|
566
|
-
* @return {?}
|
|
567
|
-
*/
|
|
568
|
-
(obj, prop) => prop.split('.').reduce((/**
|
|
569
|
-
* @param {?} acc
|
|
570
|
-
* @param {?} part
|
|
571
|
-
* @return {?}
|
|
572
|
-
*/
|
|
573
|
-
(acc, part) => acc && acc[part]), obj));
|
|
574
|
-
/**
|
|
575
|
-
* Simple object check.
|
|
576
|
-
*
|
|
577
|
-
* isObject({a:1}) //=> true
|
|
578
|
-
* isObject(1) //=> false
|
|
579
|
-
*
|
|
580
|
-
* @ignore
|
|
581
|
-
* @type {?}
|
|
582
|
-
*/
|
|
583
|
-
const isObject = (/**
|
|
584
|
-
* @param {?} item
|
|
585
|
-
* @return {?}
|
|
586
|
-
*/
|
|
587
|
-
(item) => {
|
|
588
|
-
return item && typeof item === 'object' && !Array.isArray(item);
|
|
589
|
-
});
|
|
590
|
-
/**
|
|
591
|
-
* Deep merge two objects.
|
|
592
|
-
*
|
|
593
|
-
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
594
|
-
*
|
|
595
|
-
* \@param base base object onto which `sources` will be applied
|
|
596
|
-
* @type {?}
|
|
597
|
-
*/
|
|
598
|
-
const mergeDeep = (/**
|
|
599
|
-
* @param {?} base
|
|
600
|
-
* @param {...?} sources
|
|
601
|
-
* @return {?}
|
|
602
|
-
*/
|
|
603
|
-
(base, ...sources) => {
|
|
604
|
-
if (!sources.length)
|
|
605
|
-
return base;
|
|
606
|
-
/** @type {?} */
|
|
607
|
-
const source = sources.shift();
|
|
608
|
-
if (isObject(base) && isObject(source)) {
|
|
609
|
-
for (const key in source) {
|
|
610
|
-
if (isObject(source[key])) {
|
|
611
|
-
if (!base[key])
|
|
612
|
-
Object.assign(base, { [key]: {} });
|
|
613
|
-
mergeDeep(base[key], source[key]);
|
|
614
|
-
}
|
|
615
|
-
else {
|
|
616
|
-
Object.assign(base, { [key]: source[key] });
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
return mergeDeep(base, ...sources);
|
|
621
|
-
});
|
|
622
|
-
|
|
623
480
|
/**
|
|
624
481
|
* @fileoverview added by tsickle
|
|
625
482
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -744,17 +601,6 @@ if (false) {
|
|
|
744
601
|
/** @type {?} */
|
|
745
602
|
StatesAndDefaults.prototype.states;
|
|
746
603
|
}
|
|
747
|
-
/**
|
|
748
|
-
* @record
|
|
749
|
-
* @template T
|
|
750
|
-
*/
|
|
751
|
-
function RootStateDiff() { }
|
|
752
|
-
if (false) {
|
|
753
|
-
/** @type {?} */
|
|
754
|
-
RootStateDiff.prototype.currentAppState;
|
|
755
|
-
/** @type {?} */
|
|
756
|
-
RootStateDiff.prototype.newAppState;
|
|
757
|
-
}
|
|
758
604
|
/**
|
|
759
605
|
* Ensures metadata is attached to the class and returns it.
|
|
760
606
|
*
|
|
@@ -1094,22 +940,152 @@ function topologicalSort(graph) {
|
|
|
1094
940
|
* @param {?} obj
|
|
1095
941
|
* @return {?}
|
|
1096
942
|
*/
|
|
1097
|
-
function isObject
|
|
943
|
+
function isObject(obj) {
|
|
1098
944
|
return (typeof obj === 'object' && obj !== null) || typeof obj === 'function';
|
|
1099
945
|
}
|
|
946
|
+
|
|
1100
947
|
/**
|
|
1101
|
-
* @
|
|
1102
|
-
* @
|
|
1103
|
-
|
|
948
|
+
* @fileoverview added by tsickle
|
|
949
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
950
|
+
*/
|
|
951
|
+
/**
|
|
952
|
+
* Returns the type from an action instance/class.
|
|
953
|
+
* @ignore
|
|
954
|
+
* @param {?} action
|
|
1104
955
|
* @return {?}
|
|
1105
956
|
*/
|
|
1106
|
-
function
|
|
1107
|
-
|
|
1108
|
-
|
|
957
|
+
function getActionTypeFromInstance(action) {
|
|
958
|
+
if (action.constructor && action.constructor.type) {
|
|
959
|
+
return action.constructor.type;
|
|
960
|
+
}
|
|
961
|
+
else {
|
|
962
|
+
return action.type;
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Matches a action
|
|
967
|
+
* @ignore
|
|
968
|
+
* @param {?} action1
|
|
969
|
+
* @return {?}
|
|
970
|
+
*/
|
|
971
|
+
function actionMatcher(action1) {
|
|
1109
972
|
/** @type {?} */
|
|
1110
|
-
const
|
|
1111
|
-
return
|
|
973
|
+
const type1 = getActionTypeFromInstance(action1);
|
|
974
|
+
return (/**
|
|
975
|
+
* @param {?} action2
|
|
976
|
+
* @return {?}
|
|
977
|
+
*/
|
|
978
|
+
function (action2) {
|
|
979
|
+
return type1 === getActionTypeFromInstance(action2);
|
|
980
|
+
});
|
|
1112
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* Set a deeply nested value. Example:
|
|
984
|
+
*
|
|
985
|
+
* setValue({ foo: { bar: { eat: false } } },
|
|
986
|
+
* 'foo.bar.eat', true) //=> { foo: { bar: { eat: true } } }
|
|
987
|
+
*
|
|
988
|
+
* While it traverses it also creates new objects from top down.
|
|
989
|
+
*
|
|
990
|
+
* @ignore
|
|
991
|
+
* @type {?}
|
|
992
|
+
*/
|
|
993
|
+
const setValue = (/**
|
|
994
|
+
* @param {?} obj
|
|
995
|
+
* @param {?} prop
|
|
996
|
+
* @param {?} val
|
|
997
|
+
* @return {?}
|
|
998
|
+
*/
|
|
999
|
+
(obj, prop, val) => {
|
|
1000
|
+
obj = Object.assign({}, obj);
|
|
1001
|
+
/** @type {?} */
|
|
1002
|
+
const split = prop.split('.');
|
|
1003
|
+
/** @type {?} */
|
|
1004
|
+
const lastIndex = split.length - 1;
|
|
1005
|
+
split.reduce((/**
|
|
1006
|
+
* @param {?} acc
|
|
1007
|
+
* @param {?} part
|
|
1008
|
+
* @param {?} index
|
|
1009
|
+
* @return {?}
|
|
1010
|
+
*/
|
|
1011
|
+
(acc, part, index) => {
|
|
1012
|
+
if (index === lastIndex) {
|
|
1013
|
+
acc[part] = val;
|
|
1014
|
+
}
|
|
1015
|
+
else {
|
|
1016
|
+
acc[part] = Array.isArray(acc[part]) ? acc[part].slice() : Object.assign({}, acc[part]);
|
|
1017
|
+
}
|
|
1018
|
+
return acc && acc[part];
|
|
1019
|
+
}), obj);
|
|
1020
|
+
return obj;
|
|
1021
|
+
});
|
|
1022
|
+
/**
|
|
1023
|
+
* Get a deeply nested value. Example:
|
|
1024
|
+
*
|
|
1025
|
+
* getValue({ foo: bar: [] }, 'foo.bar') //=> []
|
|
1026
|
+
*
|
|
1027
|
+
* @ignore
|
|
1028
|
+
* @type {?}
|
|
1029
|
+
*/
|
|
1030
|
+
const getValue = (/**
|
|
1031
|
+
* @param {?} obj
|
|
1032
|
+
* @param {?} prop
|
|
1033
|
+
* @return {?}
|
|
1034
|
+
*/
|
|
1035
|
+
(obj, prop) => prop.split('.').reduce((/**
|
|
1036
|
+
* @param {?} acc
|
|
1037
|
+
* @param {?} part
|
|
1038
|
+
* @return {?}
|
|
1039
|
+
*/
|
|
1040
|
+
(acc, part) => acc && acc[part]), obj));
|
|
1041
|
+
/**
|
|
1042
|
+
* Simple object check.
|
|
1043
|
+
*
|
|
1044
|
+
* isObject({a:1}) //=> true
|
|
1045
|
+
* isObject(1) //=> false
|
|
1046
|
+
*
|
|
1047
|
+
* @ignore
|
|
1048
|
+
* @type {?}
|
|
1049
|
+
*/
|
|
1050
|
+
const isObject$1 = (/**
|
|
1051
|
+
* @param {?} item
|
|
1052
|
+
* @return {?}
|
|
1053
|
+
*/
|
|
1054
|
+
(item) => {
|
|
1055
|
+
return item && typeof item === 'object' && !Array.isArray(item);
|
|
1056
|
+
});
|
|
1057
|
+
/**
|
|
1058
|
+
* Deep merge two objects.
|
|
1059
|
+
*
|
|
1060
|
+
* mergeDeep({a:1, b:{x: 1, y:2}}, {b:{x: 3}, c:4}) //=> {a:1, b:{x:3, y:2}, c:4}
|
|
1061
|
+
*
|
|
1062
|
+
* \@param base base object onto which `sources` will be applied
|
|
1063
|
+
* @type {?}
|
|
1064
|
+
*/
|
|
1065
|
+
const mergeDeep = (/**
|
|
1066
|
+
* @param {?} base
|
|
1067
|
+
* @param {...?} sources
|
|
1068
|
+
* @return {?}
|
|
1069
|
+
*/
|
|
1070
|
+
(base, ...sources) => {
|
|
1071
|
+
if (!sources.length)
|
|
1072
|
+
return base;
|
|
1073
|
+
/** @type {?} */
|
|
1074
|
+
const source = sources.shift();
|
|
1075
|
+
if (isObject$1(base) && isObject$1(source)) {
|
|
1076
|
+
for (const key in source) {
|
|
1077
|
+
if (isObject$1(source[key])) {
|
|
1078
|
+
if (!base[key])
|
|
1079
|
+
Object.assign(base, { [key]: {} });
|
|
1080
|
+
mergeDeep(base[key], source[key]);
|
|
1081
|
+
}
|
|
1082
|
+
else {
|
|
1083
|
+
Object.assign(base, { [key]: source[key] });
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
return mergeDeep(base, ...sources);
|
|
1088
|
+
});
|
|
1113
1089
|
|
|
1114
1090
|
/**
|
|
1115
1091
|
* @fileoverview added by tsickle
|
|
@@ -2113,16 +2089,6 @@ class StateContextFactory {
|
|
|
2113
2089
|
function setStateValue(currentAppState, newValue) {
|
|
2114
2090
|
/** @type {?} */
|
|
2115
2091
|
const newAppState = setValue(currentAppState, mappedStore.path, newValue);
|
|
2116
|
-
/** @type {?} */
|
|
2117
|
-
const instance = mappedStore.instance;
|
|
2118
|
-
if (instance.ngxsOnChanges) {
|
|
2119
|
-
/** @type {?} */
|
|
2120
|
-
const change = getStateDiffChanges(mappedStore, {
|
|
2121
|
-
currentAppState,
|
|
2122
|
-
newAppState
|
|
2123
|
-
});
|
|
2124
|
-
instance.ngxsOnChanges(change);
|
|
2125
|
-
}
|
|
2126
2092
|
root.setState(newAppState);
|
|
2127
2093
|
return newAppState;
|
|
2128
2094
|
// In doing this refactoring I noticed that there is a 'bug' where the
|
|
@@ -2405,7 +2371,7 @@ class StateFactory {
|
|
|
2405
2371
|
if (Array.isArray(defaults)) {
|
|
2406
2372
|
value = defaults.slice();
|
|
2407
2373
|
}
|
|
2408
|
-
else if (isObject
|
|
2374
|
+
else if (isObject(defaults)) {
|
|
2409
2375
|
value = Object.assign({}, defaults);
|
|
2410
2376
|
}
|
|
2411
2377
|
else if (defaults === undefined) {
|
|
@@ -2735,129 +2701,6 @@ if (false) {
|
|
|
2735
2701
|
StateFactory.prototype._initialState;
|
|
2736
2702
|
}
|
|
2737
2703
|
|
|
2738
|
-
/**
|
|
2739
|
-
* @fileoverview added by tsickle
|
|
2740
|
-
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
2741
|
-
*/
|
|
2742
|
-
class LifecycleStateManager {
|
|
2743
|
-
/**
|
|
2744
|
-
* @param {?} internalStateOperations
|
|
2745
|
-
* @param {?} stateContextFactory
|
|
2746
|
-
* @param {?} bootstrapper
|
|
2747
|
-
*/
|
|
2748
|
-
constructor(internalStateOperations, stateContextFactory, bootstrapper) {
|
|
2749
|
-
this.internalStateOperations = internalStateOperations;
|
|
2750
|
-
this.stateContextFactory = stateContextFactory;
|
|
2751
|
-
this.bootstrapper = bootstrapper;
|
|
2752
|
-
}
|
|
2753
|
-
/**
|
|
2754
|
-
* @template T
|
|
2755
|
-
* @param {?} action
|
|
2756
|
-
* @param {?} results
|
|
2757
|
-
* @return {?}
|
|
2758
|
-
*/
|
|
2759
|
-
ngxsBootstrap(action, results) {
|
|
2760
|
-
this.internalStateOperations
|
|
2761
|
-
.getRootStateOperations()
|
|
2762
|
-
.dispatch(action)
|
|
2763
|
-
.pipe(filter((/**
|
|
2764
|
-
* @return {?}
|
|
2765
|
-
*/
|
|
2766
|
-
() => !!results)), tap((/**
|
|
2767
|
-
* @return {?}
|
|
2768
|
-
*/
|
|
2769
|
-
() => this.invokeInit((/** @type {?} */ (results)).states))), mergeMap((/**
|
|
2770
|
-
* @return {?}
|
|
2771
|
-
*/
|
|
2772
|
-
() => this.bootstrapper.appBootstrapped$)), filter((/**
|
|
2773
|
-
* @param {?} appBootstrapped
|
|
2774
|
-
* @return {?}
|
|
2775
|
-
*/
|
|
2776
|
-
appBootstrapped => !!appBootstrapped)))
|
|
2777
|
-
.subscribe((/**
|
|
2778
|
-
* @return {?}
|
|
2779
|
-
*/
|
|
2780
|
-
() => this.invokeBootstrap((/** @type {?} */ (results)).states)));
|
|
2781
|
-
}
|
|
2782
|
-
/**
|
|
2783
|
-
* Invoke the init function on the states.
|
|
2784
|
-
* @param {?} mappedStores
|
|
2785
|
-
* @return {?}
|
|
2786
|
-
*/
|
|
2787
|
-
invokeInit(mappedStores) {
|
|
2788
|
-
for (const mappedStore of mappedStores) {
|
|
2789
|
-
/** @type {?} */
|
|
2790
|
-
const instance = mappedStore.instance;
|
|
2791
|
-
if (instance.ngxsOnChanges) {
|
|
2792
|
-
/** @type {?} */
|
|
2793
|
-
const currentAppState = {};
|
|
2794
|
-
/** @type {?} */
|
|
2795
|
-
const newAppState = this.internalStateOperations
|
|
2796
|
-
.getRootStateOperations()
|
|
2797
|
-
.getState();
|
|
2798
|
-
/** @type {?} */
|
|
2799
|
-
const firstDiffChange = getStateDiffChanges(mappedStore, {
|
|
2800
|
-
currentAppState,
|
|
2801
|
-
newAppState
|
|
2802
|
-
});
|
|
2803
|
-
instance.ngxsOnChanges(firstDiffChange);
|
|
2804
|
-
}
|
|
2805
|
-
if (instance.ngxsOnInit) {
|
|
2806
|
-
instance.ngxsOnInit(this.getStateContext(mappedStore));
|
|
2807
|
-
}
|
|
2808
|
-
mappedStore.isInitialised = true;
|
|
2809
|
-
}
|
|
2810
|
-
}
|
|
2811
|
-
/**
|
|
2812
|
-
* Invoke the bootstrap function on the states.
|
|
2813
|
-
* @param {?} mappedStores
|
|
2814
|
-
* @return {?}
|
|
2815
|
-
*/
|
|
2816
|
-
invokeBootstrap(mappedStores) {
|
|
2817
|
-
for (const mappedStore of mappedStores) {
|
|
2818
|
-
/** @type {?} */
|
|
2819
|
-
const instance = mappedStore.instance;
|
|
2820
|
-
if (instance.ngxsAfterBootstrap) {
|
|
2821
|
-
instance.ngxsAfterBootstrap(this.getStateContext(mappedStore));
|
|
2822
|
-
}
|
|
2823
|
-
}
|
|
2824
|
-
}
|
|
2825
|
-
/**
|
|
2826
|
-
* @private
|
|
2827
|
-
* @param {?} mappedStore
|
|
2828
|
-
* @return {?}
|
|
2829
|
-
*/
|
|
2830
|
-
getStateContext(mappedStore) {
|
|
2831
|
-
return this.stateContextFactory.createStateContext(mappedStore);
|
|
2832
|
-
}
|
|
2833
|
-
}
|
|
2834
|
-
LifecycleStateManager.decorators = [
|
|
2835
|
-
{ type: Injectable }
|
|
2836
|
-
];
|
|
2837
|
-
/** @nocollapse */
|
|
2838
|
-
LifecycleStateManager.ctorParameters = () => [
|
|
2839
|
-
{ type: InternalStateOperations },
|
|
2840
|
-
{ type: StateContextFactory },
|
|
2841
|
-
{ type: NgxsBootstrapper }
|
|
2842
|
-
];
|
|
2843
|
-
if (false) {
|
|
2844
|
-
/**
|
|
2845
|
-
* @type {?}
|
|
2846
|
-
* @private
|
|
2847
|
-
*/
|
|
2848
|
-
LifecycleStateManager.prototype.internalStateOperations;
|
|
2849
|
-
/**
|
|
2850
|
-
* @type {?}
|
|
2851
|
-
* @private
|
|
2852
|
-
*/
|
|
2853
|
-
LifecycleStateManager.prototype.stateContextFactory;
|
|
2854
|
-
/**
|
|
2855
|
-
* @type {?}
|
|
2856
|
-
* @private
|
|
2857
|
-
*/
|
|
2858
|
-
LifecycleStateManager.prototype.bootstrapper;
|
|
2859
|
-
}
|
|
2860
|
-
|
|
2861
2704
|
/**
|
|
2862
2705
|
* @fileoverview added by tsickle
|
|
2863
2706
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
@@ -3255,6 +3098,155 @@ if (false) {
|
|
|
3255
3098
|
Store.prototype._stateFactory;
|
|
3256
3099
|
}
|
|
3257
3100
|
|
|
3101
|
+
/**
|
|
3102
|
+
* @fileoverview added by tsickle
|
|
3103
|
+
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|
|
3104
|
+
*/
|
|
3105
|
+
class LifecycleStateManager {
|
|
3106
|
+
/**
|
|
3107
|
+
* @param {?} _store
|
|
3108
|
+
* @param {?} _internalStateOperations
|
|
3109
|
+
* @param {?} _stateContextFactory
|
|
3110
|
+
* @param {?} _bootstrapper
|
|
3111
|
+
*/
|
|
3112
|
+
constructor(_store, _internalStateOperations, _stateContextFactory, _bootstrapper) {
|
|
3113
|
+
this._store = _store;
|
|
3114
|
+
this._internalStateOperations = _internalStateOperations;
|
|
3115
|
+
this._stateContextFactory = _stateContextFactory;
|
|
3116
|
+
this._bootstrapper = _bootstrapper;
|
|
3117
|
+
this._destroy$ = new Subject();
|
|
3118
|
+
}
|
|
3119
|
+
/**
|
|
3120
|
+
* @return {?}
|
|
3121
|
+
*/
|
|
3122
|
+
ngOnDestroy() {
|
|
3123
|
+
this._destroy$.next();
|
|
3124
|
+
}
|
|
3125
|
+
/**
|
|
3126
|
+
* @template T
|
|
3127
|
+
* @param {?} action
|
|
3128
|
+
* @param {?} results
|
|
3129
|
+
* @return {?}
|
|
3130
|
+
*/
|
|
3131
|
+
ngxsBootstrap(action, results) {
|
|
3132
|
+
this._internalStateOperations
|
|
3133
|
+
.getRootStateOperations()
|
|
3134
|
+
.dispatch(action)
|
|
3135
|
+
.pipe(filter((/**
|
|
3136
|
+
* @return {?}
|
|
3137
|
+
*/
|
|
3138
|
+
() => !!results)), tap((/**
|
|
3139
|
+
* @return {?}
|
|
3140
|
+
*/
|
|
3141
|
+
() => this._invokeInit((/** @type {?} */ (results)).states))), mergeMap((/**
|
|
3142
|
+
* @return {?}
|
|
3143
|
+
*/
|
|
3144
|
+
() => this._bootstrapper.appBootstrapped$)), filter((/**
|
|
3145
|
+
* @param {?} appBootstrapped
|
|
3146
|
+
* @return {?}
|
|
3147
|
+
*/
|
|
3148
|
+
appBootstrapped => !!appBootstrapped)), takeUntil(this._destroy$))
|
|
3149
|
+
.subscribe((/**
|
|
3150
|
+
* @return {?}
|
|
3151
|
+
*/
|
|
3152
|
+
() => this._invokeBootstrap((/** @type {?} */ (results)).states)));
|
|
3153
|
+
}
|
|
3154
|
+
/**
|
|
3155
|
+
* Invoke the init function on the states.
|
|
3156
|
+
* @private
|
|
3157
|
+
* @param {?} mappedStores
|
|
3158
|
+
* @return {?}
|
|
3159
|
+
*/
|
|
3160
|
+
_invokeInit(mappedStores) {
|
|
3161
|
+
for (const mappedStore of mappedStores) {
|
|
3162
|
+
/** @type {?} */
|
|
3163
|
+
const instance = mappedStore.instance;
|
|
3164
|
+
if (instance.ngxsOnChanges) {
|
|
3165
|
+
this._store
|
|
3166
|
+
.select((/**
|
|
3167
|
+
* @param {?} state
|
|
3168
|
+
* @return {?}
|
|
3169
|
+
*/
|
|
3170
|
+
state => getValue(state, mappedStore.path)))
|
|
3171
|
+
.pipe(startWith(undefined), pairwise(), takeUntil(this._destroy$))
|
|
3172
|
+
.subscribe((/**
|
|
3173
|
+
* @param {?} __0
|
|
3174
|
+
* @return {?}
|
|
3175
|
+
*/
|
|
3176
|
+
([previousValue, currentValue]) => {
|
|
3177
|
+
/** @type {?} */
|
|
3178
|
+
const change = new NgxsSimpleChange(previousValue, currentValue, !mappedStore.isInitialised);
|
|
3179
|
+
(/** @type {?} */ (instance.ngxsOnChanges))(change);
|
|
3180
|
+
}));
|
|
3181
|
+
}
|
|
3182
|
+
if (instance.ngxsOnInit) {
|
|
3183
|
+
instance.ngxsOnInit(this._getStateContext(mappedStore));
|
|
3184
|
+
}
|
|
3185
|
+
mappedStore.isInitialised = true;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
/**
|
|
3189
|
+
* Invoke the bootstrap function on the states.
|
|
3190
|
+
* @private
|
|
3191
|
+
* @param {?} mappedStores
|
|
3192
|
+
* @return {?}
|
|
3193
|
+
*/
|
|
3194
|
+
_invokeBootstrap(mappedStores) {
|
|
3195
|
+
for (const mappedStore of mappedStores) {
|
|
3196
|
+
/** @type {?} */
|
|
3197
|
+
const instance = mappedStore.instance;
|
|
3198
|
+
if (instance.ngxsAfterBootstrap) {
|
|
3199
|
+
instance.ngxsAfterBootstrap(this._getStateContext(mappedStore));
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
}
|
|
3203
|
+
/**
|
|
3204
|
+
* @private
|
|
3205
|
+
* @param {?} mappedStore
|
|
3206
|
+
* @return {?}
|
|
3207
|
+
*/
|
|
3208
|
+
_getStateContext(mappedStore) {
|
|
3209
|
+
return this._stateContextFactory.createStateContext(mappedStore);
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
LifecycleStateManager.decorators = [
|
|
3213
|
+
{ type: Injectable }
|
|
3214
|
+
];
|
|
3215
|
+
/** @nocollapse */
|
|
3216
|
+
LifecycleStateManager.ctorParameters = () => [
|
|
3217
|
+
{ type: Store },
|
|
3218
|
+
{ type: InternalStateOperations },
|
|
3219
|
+
{ type: StateContextFactory },
|
|
3220
|
+
{ type: NgxsBootstrapper }
|
|
3221
|
+
];
|
|
3222
|
+
if (false) {
|
|
3223
|
+
/**
|
|
3224
|
+
* @type {?}
|
|
3225
|
+
* @private
|
|
3226
|
+
*/
|
|
3227
|
+
LifecycleStateManager.prototype._destroy$;
|
|
3228
|
+
/**
|
|
3229
|
+
* @type {?}
|
|
3230
|
+
* @private
|
|
3231
|
+
*/
|
|
3232
|
+
LifecycleStateManager.prototype._store;
|
|
3233
|
+
/**
|
|
3234
|
+
* @type {?}
|
|
3235
|
+
* @private
|
|
3236
|
+
*/
|
|
3237
|
+
LifecycleStateManager.prototype._internalStateOperations;
|
|
3238
|
+
/**
|
|
3239
|
+
* @type {?}
|
|
3240
|
+
* @private
|
|
3241
|
+
*/
|
|
3242
|
+
LifecycleStateManager.prototype._stateContextFactory;
|
|
3243
|
+
/**
|
|
3244
|
+
* @type {?}
|
|
3245
|
+
* @private
|
|
3246
|
+
*/
|
|
3247
|
+
LifecycleStateManager.prototype._bootstrapper;
|
|
3248
|
+
}
|
|
3249
|
+
|
|
3258
3250
|
/**
|
|
3259
3251
|
* @fileoverview added by tsickle
|
|
3260
3252
|
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
|