refactor: Revert "refactor(core): Use typedi to manage EventBus singletons (#5795)" (no-changelog) (#5825)

Revert "refactor(core): Use typedi to manage EventBus singletons (no-changelog) (#5795)"

This reverts commit 522c790817.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-30 09:59:04 +02:00
committed by GitHub
parent 6c35ffa82c
commit 58fda255fe
15 changed files with 154 additions and 145 deletions

View File

@@ -1,24 +1,17 @@
import { Container } from 'typedi';
import { jsonStringify, LoggerProxy as Logger } from 'n8n-workflow';
import type { IPushDataType } from '@/Interfaces';
import { MessageEventBus } from '@/eventbus';
import { eventBus } from '../eventbus';
export abstract class AbstractPush<T> {
protected connections: Record<string, T> = {};
protected eventBus: MessageEventBus;
constructor() {
this.eventBus = Container.get(MessageEventBus);
}
protected abstract close(connection: T): void;
protected abstract sendToOne(connection: T, data: string): void;
protected add(sessionId: string, connection: T): void {
const { connections } = this;
Logger.debug('Add editor-UI session', { sessionId });
this.eventBus.emit('editorUiConnected', sessionId);
eventBus.emit('editorUiConnected', sessionId);
const existingConnection = connections[sessionId];
if (existingConnection) {