From da818b040acc45a24810347c156afce28088379e Mon Sep 17 00:00:00 2001 From: qschroter Date: Tue, 21 Nov 2023 17:36:52 +0100 Subject: [PATCH] Prevent multiple instance of eventQueue --- src/Bones.UI/core/eventQueue.ts | 7 +++---- src/Bones.UI/shims-plugin.d.ts | 8 +++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Bones.UI/core/eventQueue.ts b/src/Bones.UI/core/eventQueue.ts index cc4cc61..50188a7 100644 --- a/src/Bones.UI/core/eventQueue.ts +++ b/src/Bones.UI/core/eventQueue.ts @@ -29,7 +29,6 @@ export class EventQueue { private subscribers: EventQueueSubscriber[]; private validator: ValidateFunction; - private constructor() { this.subscriptionCounter = 0; this.subscribers = []; @@ -46,11 +45,11 @@ export class EventQueue { } public static get instance(): EventQueue { - if (!EventQueue._instance) { - EventQueue._instance = new EventQueue(); + if (!window._bonesQueue) { + window._bonesQueue = new EventQueue(); } - return EventQueue._instance; + return window._bonesQueue; } public publish(topic: string, payload: any): void { diff --git a/src/Bones.UI/shims-plugin.d.ts b/src/Bones.UI/shims-plugin.d.ts index c95a057..b0b8c43 100644 --- a/src/Bones.UI/shims-plugin.d.ts +++ b/src/Bones.UI/shims-plugin.d.ts @@ -9,4 +9,10 @@ declare module 'vue' { has(permissionCode: string): boolean; }; } -} \ No newline at end of file +} + +declare global { + interface Window { + _bonesQueue: any; + } + } \ No newline at end of file