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:
parent
414ef1caaf
commit
4b4dbdc0d6
11 changed files with 76 additions and 228 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { EventBus } from '../core/EventBus';
|
||||
import { CalendarView, IEventBus } from '../types/CalendarTypes';
|
||||
import { calendarConfig } from '../core/CalendarConfig';
|
||||
import { EventTypes } from '../constants/EventTypes';
|
||||
import { CoreEvents } from '../constants/CoreEvents';
|
||||
|
||||
/**
|
||||
* ViewManager - Håndterer skift mellem dag/uge/måned visninger
|
||||
|
|
@ -21,13 +21,13 @@ export class ViewManager {
|
|||
private setupEventListeners(): void {
|
||||
// Track event bus listeners for cleanup
|
||||
this.eventCleanup.push(
|
||||
this.eventBus.on(EventTypes.CALENDAR_INITIALIZED, () => {
|
||||
this.eventBus.on(CoreEvents.INITIALIZED, () => {
|
||||
this.initializeView();
|
||||
})
|
||||
);
|
||||
|
||||
this.eventCleanup.push(
|
||||
this.eventBus.on(EventTypes.VIEW_CHANGE_REQUESTED, (event: Event) => {
|
||||
this.eventBus.on(CoreEvents.VIEW_CHANGED, (event: Event) => {
|
||||
const customEvent = event as CustomEvent;
|
||||
const { currentView } = customEvent.detail;
|
||||
this.changeView(currentView);
|
||||
|
|
@ -35,7 +35,7 @@ export class ViewManager {
|
|||
);
|
||||
|
||||
this.eventCleanup.push(
|
||||
this.eventBus.on(EventTypes.DATE_CHANGED, () => {
|
||||
this.eventBus.on(CoreEvents.DATE_CHANGED, () => {
|
||||
this.refreshCurrentView();
|
||||
})
|
||||
);
|
||||
|
|
@ -83,7 +83,7 @@ export class ViewManager {
|
|||
this.updateViewButtons();
|
||||
this.updateWorkweekButtons();
|
||||
|
||||
this.eventBus.emit(EventTypes.VIEW_RENDERED, {
|
||||
this.eventBus.emit(CoreEvents.VIEW_RENDERED, {
|
||||
view: this.currentView
|
||||
});
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ export class ViewManager {
|
|||
|
||||
this.updateViewButtons();
|
||||
|
||||
this.eventBus.emit(EventTypes.VIEW_CHANGED, {
|
||||
this.eventBus.emit(CoreEvents.VIEW_CHANGED, {
|
||||
previousView,
|
||||
currentView: newView
|
||||
});
|
||||
|
|
@ -114,7 +114,7 @@ export class ViewManager {
|
|||
this.updateWorkweekButtons();
|
||||
|
||||
// Trigger a calendar refresh to apply the new workweek
|
||||
this.eventBus.emit(EventTypes.REFRESH_REQUESTED);
|
||||
this.eventBus.emit(CoreEvents.REFRESH_REQUESTED);
|
||||
}
|
||||
|
||||
private updateViewButtons(): void {
|
||||
|
|
@ -144,7 +144,7 @@ export class ViewManager {
|
|||
}
|
||||
|
||||
private refreshCurrentView(): void {
|
||||
this.eventBus.emit(EventTypes.VIEW_RENDERED, {
|
||||
this.eventBus.emit(CoreEvents.VIEW_RENDERED, {
|
||||
view: this.currentView
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue