import type { DomainEvent } from "@tff/core"; import type { EventBus } from "../../../domain/ports/event-bus.port.js"; export class SimpleEventBus implements EventBus { private handlers = new Map) => void>>(); publish(event: DomainEvent): void { const handlers = this.handlers.get(event.eventName) ?? []; for (const handler of handlers) { handler(event); } } subscribe(type: string, handler: (event: DomainEvent) => void): void { const existing = this.handlers.get(type) ?? []; this.handlers.set(type, [...existing, handler]); } }