mobx-route 0.6.1 → 0.6.2
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.
|
@@ -30,6 +30,8 @@ export declare class VirtualRoute<TParams extends AnyObject | EmptyObject = Empt
|
|
|
30
30
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close-void)
|
|
31
31
|
*/
|
|
32
32
|
close(): void;
|
|
33
|
+
private firstOpenedStateCheck;
|
|
34
|
+
private processOpenedState;
|
|
33
35
|
destroy(): void;
|
|
34
36
|
}
|
|
35
37
|
//# sourceMappingURL=virtual-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-route.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAI/E,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAElC;;;;GAIG;AACH,qBAAa,YAAY,CAAC,OAAO,SAAS,SAAS,GAAG,WAAW,GAAG,WAAW,CAC7E,YAAW,oBAAoB,CAAC,OAAO,CAAC;IAU5B,SAAS,CAAC,MAAM,EAAE,yBAAyB,CAAC,OAAO,CAAC;IARhE,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC;IAC3C,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IAEvB,OAAO,CAAC,aAAa,CAAU;IAE/B,OAAO,CAAC,WAAW,CAA2D;gBAExD,MAAM,GAAE,yBAAyB,CAAC,OAAO,CAAM;
|
|
1
|
+
{"version":3,"file":"virtual-route.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.ts"],"names":[],"mappings":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|
makeObservable(this);
|
|
32
32
|
let dispose;
|
|
33
|
-
let firstReactionCall = true;
|
|
34
33
|
onBecomeObserved(this, 'isOpened', () => {
|
|
35
34
|
if (!config.afterOpen && !config.afterClose) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
|
-
dispose = reaction(() => this.isOpened,
|
|
39
|
-
if (firstReactionCall) {
|
|
40
|
-
firstReactionCall = false;
|
|
41
|
-
// ignore first 'afterClose' callback call
|
|
42
|
-
if (!isOpened) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (isOpened) {
|
|
47
|
-
config.afterOpen?.(this.params, this);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
config.afterClose?.();
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
37
|
+
dispose = reaction(() => this.isOpened, this.processOpenedState, {
|
|
53
38
|
signal: this.abortController.signal,
|
|
54
39
|
fireImmediately: true,
|
|
55
40
|
});
|
|
@@ -96,6 +81,9 @@ export class VirtualRoute {
|
|
|
96
81
|
if (!this.isLocalOpened) {
|
|
97
82
|
return;
|
|
98
83
|
}
|
|
84
|
+
if (this.isOpened) {
|
|
85
|
+
this.config.afterOpen?.(this.params, this);
|
|
86
|
+
}
|
|
99
87
|
if (extraParams?.query) {
|
|
100
88
|
this.query.update(extraParams.query, extraParams.replace);
|
|
101
89
|
}
|
|
@@ -117,6 +105,22 @@ export class VirtualRoute {
|
|
|
117
105
|
}
|
|
118
106
|
this.params = null;
|
|
119
107
|
}
|
|
108
|
+
firstOpenedStateCheck = true;
|
|
109
|
+
processOpenedState = (isOpened) => {
|
|
110
|
+
if (this.firstOpenedStateCheck) {
|
|
111
|
+
this.firstOpenedStateCheck = false;
|
|
112
|
+
// ignore first 'afterClose' callback call
|
|
113
|
+
if (!isOpened) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (isOpened) {
|
|
118
|
+
this.config.afterOpen?.(this.params, this);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.config.afterClose?.();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
120
124
|
destroy() {
|
|
121
125
|
this.abortController.abort();
|
|
122
126
|
}
|