From e7ebb9210463d79ec3f66c57fe64747a5a046722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Mon, 4 Sep 2023 14:52:37 +0200 Subject: [PATCH] [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 --- src/runtime/app.ts | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/runtime/app.ts b/src/runtime/app.ts index 9e8a99f3..ace8fd1c 100644 --- a/src/runtime/app.ts +++ b/src/runtime/app.ts @@ -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.`; }; +const apps = new Set(); + declare global { interface Window { __OWL_DEVTOOLS__: { @@ -47,13 +49,7 @@ declare global { } } -window.__OWL_DEVTOOLS__ ||= { - apps: new Set(), - Fiber: Fiber, - RootFiber: RootFiber, - toRaw: toRaw, - reactive: reactive, -}; +window.__OWL_DEVTOOLS__ ||= { apps, Fiber, RootFiber, toRaw, reactive }; export class App< T extends abstract new (...args: any) => any = any, @@ -61,6 +57,7 @@ export class App< E = any > extends TemplateSet { static validateTarget = validateTarget; + static apps = apps; static version = version; name: string; @@ -75,7 +72,7 @@ export class App< super(config); this.name = config.name || ""; this.Root = Root; - window.__OWL_DEVTOOLS__.apps.add(this); + apps.add(this); if (config.test) { this.dev = true; } @@ -140,7 +137,7 @@ export class App< this.root.destroy(); this.scheduler.processTasks(); } - window.__OWL_DEVTOOLS__.apps.delete(this); + apps.delete(this); } createComponent

(