diff --git a/src/backend/model/extension/ExtensionDecorator.ts b/src/backend/model/extension/ExtensionDecorator.ts index ddff3c3f..a0870f49 100644 --- a/src/backend/model/extension/ExtensionDecorator.ts +++ b/src/backend/model/extension/ExtensionDecorator.ts @@ -1,7 +1,15 @@ import {IExtensionEvent, IExtensionEvents} from './IExtension'; -import {ObjectManagers} from '../ObjectManagers'; import {ExtensionEvent} from './ExtensionEvent'; +export class ExtensionDecoratorObject { + public static events: IExtensionEvents; + + static init(events: IExtensionEvents) { + this.events = events; + } + +} + export const ExtensionDecorator = (fn: (ee: IExtensionEvents) => IExtensionEvent) => { return ( target: unknown, @@ -11,11 +19,11 @@ export const ExtensionDecorator = (fn: (ee: IExtensionEvents) = const targetMethod = descriptor.value; descriptor.value = async function(...args: I) { - if (!ObjectManagers.isReady()) { + if (!ExtensionDecoratorObject.events) { return await targetMethod.apply(this, args); } - const event = fn(ObjectManagers.getInstance().ExtensionManager.events) as ExtensionEvent; + const event = fn(ExtensionDecoratorObject.events) as ExtensionEvent; const eventObj = {stopPropagation: false}; const input = await event.triggerBefore({inputs: args}, eventObj); diff --git a/src/backend/model/extension/ExtensionManager.ts b/src/backend/model/extension/ExtensionManager.ts index 5d761e96..c98a6e69 100644 --- a/src/backend/model/extension/ExtensionManager.ts +++ b/src/backend/model/extension/ExtensionManager.ts @@ -10,6 +10,7 @@ import {ExtensionEvent} from './ExtensionEvent'; import * as express from 'express'; import {SQLConnection} from '../database/SQLConnection'; import {ExtensionObject} from './ExtensionObject'; +import {ExtensionDecoratorObject} from './ExtensionDecorator'; const LOG_TAG = '[ExtensionManager]'; @@ -57,6 +58,7 @@ export class ExtensionManager implements IObjectManager { } } }; + ExtensionDecoratorObject.init(this.events); } public loadExtensionsList() {