mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[IMP] app: export apps set as static property
Before this commit, Owl would export the list of apps in a global object `__OWL_DEVTOOLS__`. However, it is sometimes useful to be able to access that set, even outside of the devtools (for example, to register templates in all active apps). closes #1515
This commit is contained in:
committed by
Sam Degueldre
parent
c78e070636
commit
e7ebb92104
+6
-9
@@ -35,6 +35,8 @@ This is not suitable for production use.
|
|||||||
See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration for more information.`;
|
See https://github.com/odoo/owl/blob/${hash}/doc/reference/app.md#configuration for more information.`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const apps = new Set<App>();
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Window {
|
interface Window {
|
||||||
__OWL_DEVTOOLS__: {
|
__OWL_DEVTOOLS__: {
|
||||||
@@ -47,13 +49,7 @@ declare global {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.__OWL_DEVTOOLS__ ||= {
|
window.__OWL_DEVTOOLS__ ||= { apps, Fiber, RootFiber, toRaw, reactive };
|
||||||
apps: new Set<App>(),
|
|
||||||
Fiber: Fiber,
|
|
||||||
RootFiber: RootFiber,
|
|
||||||
toRaw: toRaw,
|
|
||||||
reactive: reactive,
|
|
||||||
};
|
|
||||||
|
|
||||||
export class App<
|
export class App<
|
||||||
T extends abstract new (...args: any) => any = any,
|
T extends abstract new (...args: any) => any = any,
|
||||||
@@ -61,6 +57,7 @@ export class App<
|
|||||||
E = any
|
E = any
|
||||||
> extends TemplateSet {
|
> extends TemplateSet {
|
||||||
static validateTarget = validateTarget;
|
static validateTarget = validateTarget;
|
||||||
|
static apps = apps;
|
||||||
static version = version;
|
static version = version;
|
||||||
|
|
||||||
name: string;
|
name: string;
|
||||||
@@ -75,7 +72,7 @@ export class App<
|
|||||||
super(config);
|
super(config);
|
||||||
this.name = config.name || "";
|
this.name = config.name || "";
|
||||||
this.Root = Root;
|
this.Root = Root;
|
||||||
window.__OWL_DEVTOOLS__.apps.add(this);
|
apps.add(this);
|
||||||
if (config.test) {
|
if (config.test) {
|
||||||
this.dev = true;
|
this.dev = true;
|
||||||
}
|
}
|
||||||
@@ -140,7 +137,7 @@ export class App<
|
|||||||
this.root.destroy();
|
this.root.destroy();
|
||||||
this.scheduler.processTasks();
|
this.scheduler.processTasks();
|
||||||
}
|
}
|
||||||
window.__OWL_DEVTOOLS__.apps.delete(this);
|
apps.delete(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
createComponent<P extends Props>(
|
createComponent<P extends Props>(
|
||||||
|
|||||||
Reference in New Issue
Block a user