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

@ -1,7 +1,7 @@
// Calendar configuration management
import { eventBus } from './EventBus';
import { EventTypes } from '../constants/EventTypes';
import { CoreEvents } from '../constants/CoreEvents';
import { CalendarConfig as ICalendarConfig, ViewPeriod, CalendarMode, DateViewType, CalendarType } from '../types/CalendarTypes';
/**
@ -215,7 +215,7 @@ export class CalendarConfig {
// Update computed values handled in specific update methods
// Emit config update event
eventBus.emit(EventTypes.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
key,
value,
oldValue
@ -292,7 +292,7 @@ export class CalendarConfig {
}
// Emit grid settings update event
eventBus.emit(EventTypes.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
key: 'gridSettings',
value: this.gridSettings,
oldValue: this.gridSettings
@ -320,7 +320,7 @@ export class CalendarConfig {
this.dateViewSettings = { ...this.dateViewSettings, ...updates };
// Emit date view settings update event
eventBus.emit(EventTypes.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
key: 'dateViewSettings',
value: this.dateViewSettings,
oldValue: this.dateViewSettings
@ -355,7 +355,7 @@ export class CalendarConfig {
this.resourceViewSettings = { ...this.resourceViewSettings, ...updates };
// Emit resource view settings update event
eventBus.emit(EventTypes.CONFIG_UPDATE, {
eventBus.emit(CoreEvents.CONFIG_UPDATE, {
key: 'resourceViewSettings',
value: this.resourceViewSettings,
oldValue: this.resourceViewSettings
@ -409,7 +409,7 @@ export class CalendarConfig {
this.calendarMode = mode;
// Emit calendar mode change event
eventBus.emit(EventTypes.CALENDAR_TYPE_CHANGED, {
eventBus.emit(CoreEvents.CALENDAR_TYPE_CHANGED, {
oldType: oldMode,
newType: mode
});
@ -429,7 +429,7 @@ export class CalendarConfig {
this.selectedDate = date;
// Emit date change event
eventBus.emit(EventTypes.SELECTED_DATE_CHANGED, {
eventBus.emit(CoreEvents.SELECTED_DATE_CHANGED, {
date: date
});
}
@ -492,7 +492,7 @@ export class CalendarConfig {
this.dateViewSettings.weekDays = presets[workWeekId].totalDays;
// Emit work week change event
eventBus.emit(EventTypes.WORKWEEK_CHANGED, {
eventBus.emit(CoreEvents.WORKWEEK_CHANGED, {
workWeekId: workWeekId,
settings: presets[workWeekId]
});