Skip to content

Introducing Event-Driven Architecture #191

@KubrickCode

Description

@KubrickCode

Reduce coupling between managers with a central event bus.

type EventMap = {
  'config:changed': { scope: ConfigurationTarget; buttons: ButtonConfig[] };
  'buttonSet:switched': { from: string | null; to: string | null };
  'button:executed': { buttonId: string; command: string; timestamp: number };
  'import:completed': { strategy: ImportStrategy; count: number };
  'terminal:created': { terminalId: string; buttonId: string };
};

class EventBus {
  on<K extends keyof EventMap>(event: K, handler: EventHandler<EventMap[K]>): Disposable;
  emit<K extends keyof EventMap>(event: K, payload: EventMap[K]>): Promise<void>;
}

Current: ConfigManager directly calls StatusBarManager.refresh()
Improved: ConfigManager emits a 'config:changed' event → Interested parties subscribe to it.

  • Decoupled managers.
  • Easier testing.
  • Adding new features doesn't require modifying existing code.

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions