mobx-route 0.6.0 → 0.6.1
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"virtual-route.d.ts","sourceRoot":"","sources":["../../../src/core/virtual-route/virtual-route.ts"],"names":[],"mappings":"
|
|
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;IAoDrE;;OAEG;IACH,IAAI,QAAQ,YAGX;IAED;;OAEG;IACH,cAAc,CACZ,WAAW,EAAE,KAAK,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC;IAKvE;;OAEG;IACH,IAAI,CACF,GAAG,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,IAAI,GACpC,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,EAAE,sBAAsB,CAAC,GAC/D,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,sBAAsB,CAAC,GAC1D,OAAO,CAAC,IAAI,CAAC;IAqChB;;OAEG;IACH,KAAK;IAYL,OAAO;CAGR"}
|
|
@@ -20,8 +20,9 @@ export class VirtualRoute {
|
|
|
20
20
|
this.query = config.queryParams ?? routeConfig.get().queryParams;
|
|
21
21
|
this.params = callFunction(config.initialParams, this) ?? null;
|
|
22
22
|
this.openChecker = config.checkOpened;
|
|
23
|
-
this.isLocalOpened =
|
|
23
|
+
this.isLocalOpened = this.openChecker?.(this) ?? false;
|
|
24
24
|
observable(this, 'params');
|
|
25
|
+
observable.ref(this, 'isLocalOpened');
|
|
25
26
|
observable.ref(this, '_isOpened');
|
|
26
27
|
computed.struct(this, 'isOpened');
|
|
27
28
|
action(this, 'setOpenChecker');
|
|
@@ -63,7 +64,7 @@ export class VirtualRoute {
|
|
|
63
64
|
*/
|
|
64
65
|
get isOpened() {
|
|
65
66
|
const isOuterOpened = this.openChecker == null || this.openChecker(this);
|
|
66
|
-
return this.isLocalOpened
|
|
67
|
+
return this.isLocalOpened && isOuterOpened;
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
70
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker-openchecker-void)
|
|
@@ -81,12 +82,16 @@ export class VirtualRoute {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
if (this.config.open == null) {
|
|
84
|
-
|
|
85
|
+
runInAction(() => {
|
|
86
|
+
this.isLocalOpened = true;
|
|
87
|
+
});
|
|
85
88
|
}
|
|
86
89
|
else {
|
|
87
90
|
const result = await this.config.open(params, this);
|
|
88
91
|
// because result can return void so this is truthy for opening state
|
|
89
|
-
|
|
92
|
+
runInAction(() => {
|
|
93
|
+
this.isLocalOpened = result !== false;
|
|
94
|
+
});
|
|
90
95
|
}
|
|
91
96
|
if (!this.isLocalOpened) {
|
|
92
97
|
return;
|
|
@@ -103,16 +108,14 @@ export class VirtualRoute {
|
|
|
103
108
|
*/
|
|
104
109
|
close() {
|
|
105
110
|
if (this.config.close == null) {
|
|
106
|
-
this.isLocalOpened
|
|
111
|
+
this.isLocalOpened = false;
|
|
107
112
|
}
|
|
108
113
|
else {
|
|
109
114
|
const result = this.config.close(this);
|
|
110
115
|
// because result can return void so this is truthy for opening state
|
|
111
|
-
this.isLocalOpened
|
|
116
|
+
this.isLocalOpened = result !== false;
|
|
112
117
|
}
|
|
113
|
-
|
|
114
|
-
this.params = null;
|
|
115
|
-
});
|
|
118
|
+
this.params = null;
|
|
116
119
|
}
|
|
117
120
|
destroy() {
|
|
118
121
|
this.abortController.abort();
|