Skip to content

Commit

Permalink
Prevent multiple instance of eventQueue
Browse files Browse the repository at this point in the history
  • Loading branch information
SchroterQuentin committed Nov 21, 2023
1 parent cd678c6 commit da818b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/Bones.UI/core/eventQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export class EventQueue {
private subscribers: EventQueueSubscriber[];
private validator: ValidateFunction<WindowsMessage>;


private constructor() {
this.subscriptionCounter = 0;
this.subscribers = [];
Expand All @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion src/Bones.UI/shims-plugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ declare module 'vue' {
has(permissionCode: string): boolean;
};
}
}
}

declare global {
interface Window {
_bonesQueue: any;
}
}

0 comments on commit da818b0

Please sign in to comment.