Refactors event system to use CoreEvents

Migrates the application to use a new CoreEvents system.

This change removes the legacy EventTypes constant file and updates all managers, renderers, and core components to use the CoreEvents constant file for event emission and subscription.

This improves code maintainability and promotes a consistent eventing strategy across the application. Adds validation to EventBus emit and extractCategory functions.
This commit is contained in:
Janus Knudsen 2025-08-20 20:22:51 +02:00
parent 414ef1caaf
commit 4b4dbdc0d6
11 changed files with 76 additions and 228 deletions

View file

@ -60,6 +60,12 @@ export class EventBus implements IEventBus {
* Emit an event via DOM CustomEvent
*/
emit(eventType: string, detail: any = {}): boolean {
// Validate eventType
if (!eventType || typeof eventType !== 'string') {
console.error('EventBus.emit: Invalid eventType provided', eventType);
return false;
}
const event = new CustomEvent(eventType, {
detail,
bubbles: true,
@ -106,6 +112,11 @@ export class EventBus implements IEventBus {
* Extract category from event type
*/
private extractCategory(eventType: string): string {
if (!eventType || typeof eventType !== 'string') {
console.error('EventBus.extractCategory: Invalid eventType', eventType);
return 'unknown';
}
if (eventType.includes(':')) {
return eventType.split(':')[0];
}