fixed naming convention and text casing to use CamelCase on class fields. Process manager implemented, not tested, needs integration with current shell implementation

This commit is contained in:
2026-08-20 09:44:03 +02:00
parent 075c999435
commit 16a1805f25
5 changed files with 141 additions and 83 deletions
+7 -7
View File
@@ -1,26 +1,26 @@
export class EventEmitter<TEvents> {
private handlers: Map<keyof TEvents, Set<Function>> = new Map();
private Handlers: Map<keyof TEvents, Set<Function>> = new Map();
public on<K extends keyof TEvents>(type: K, handler: (payload: TEvents[K]) => void): () => void {
const listeners = this.handlers.get(type);
const listeners = this.Handlers.get(type);
if (listeners) {
listeners.add(handler);
} else {
const set: Set<Function> = new Set();
set.add(handler);
this.handlers.set(type, set);
this.Handlers.set(type, set);
}
return (): void => this.off(type, handler);
}
public off<K extends keyof TEvents>(type: K, handler: (payload: TEvents[K]) => void): void {
this.handlers.get(type)?.delete(handler);
this.Handlers.get(type)?.delete(handler);
}
public once<K extends keyof TEvents>(type: K, handler: (payload: TEvents[K]) => void): () => void {
const listeners = this.handlers.get(type);
const listeners = this.Handlers.get(type);
const wrapper = (payload: TEvents[K]) => {
handler(payload);
@@ -32,14 +32,14 @@ export class EventEmitter<TEvents> {
} else {
const set: Set<Function> = new Set();
set.add(wrapper);
this.handlers.set(type, set);
this.Handlers.set(type, set);
}
return (): void => this.off(type, wrapper);
}
public emit<K extends keyof TEvents>(type: K, payload: TEvents[K]): void {
const listeners = this.handlers.get(type);
const listeners = this.Handlers.get(type);
if (listeners) {
for (const listener of [...listeners]) {