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
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import { eventBus } from '../core/EventBus';
|
||||
import { calendarConfig } from '../core/CalendarConfig';
|
||||
import { EventTypes } from '../constants/EventTypes';
|
||||
import { CoreEvents } from '../constants/CoreEvents';
|
||||
import { ResourceCalendarData, CalendarView } from '../types/CalendarTypes';
|
||||
import { AllDayEvent } from '../types/EventTypes';
|
||||
|
|
@ -48,7 +47,7 @@ export class GridManager {
|
|||
private subscribeToEvents(): void {
|
||||
// Listen for view changes to switch strategies
|
||||
this.eventCleanup.push(
|
||||
eventBus.on(EventTypes.VIEW_CHANGED, (e: Event) => {
|
||||
eventBus.on(CoreEvents.VIEW_CHANGED, (e: Event) => {
|
||||
const detail = (e as CustomEvent).detail;
|
||||
this.switchViewStrategy(detail.currentView);
|
||||
})
|
||||
|
|
@ -56,7 +55,7 @@ export class GridManager {
|
|||
|
||||
// Listen for data changes
|
||||
this.eventCleanup.push(
|
||||
eventBus.on(EventTypes.DATE_CHANGED, (e: Event) => {
|
||||
eventBus.on(CoreEvents.DATE_CHANGED, (e: Event) => {
|
||||
const detail = (e as CustomEvent).detail;
|
||||
this.currentDate = detail.currentDate;
|
||||
this.render();
|
||||
|
|
@ -64,7 +63,7 @@ export class GridManager {
|
|||
);
|
||||
|
||||
this.eventCleanup.push(
|
||||
eventBus.on(EventTypes.WEEK_CHANGED, (e: Event) => {
|
||||
eventBus.on(CoreEvents.WEEK_CHANGED, (e: Event) => {
|
||||
const detail = (e as CustomEvent).detail;
|
||||
this.currentDate = detail.weekStart;
|
||||
this.render();
|
||||
|
|
@ -72,7 +71,7 @@ export class GridManager {
|
|||
);
|
||||
|
||||
this.eventCleanup.push(
|
||||
eventBus.on(EventTypes.EVENTS_LOADED, (e: Event) => {
|
||||
eventBus.on(CoreEvents.DATA_LOADED, (e: Event) => {
|
||||
const detail = (e as CustomEvent).detail;
|
||||
this.updateAllDayEvents(detail.events);
|
||||
})
|
||||
|
|
@ -80,13 +79,13 @@ export class GridManager {
|
|||
|
||||
// Listen for config changes that affect rendering
|
||||
this.eventCleanup.push(
|
||||
eventBus.on(EventTypes.CONFIG_UPDATE, (e: Event) => {
|
||||
eventBus.on(CoreEvents.REFRESH_REQUESTED, (e: Event) => {
|
||||
this.render();
|
||||
})
|
||||
);
|
||||
|
||||
this.eventCleanup.push(
|
||||
eventBus.on(EventTypes.WORKWEEK_CHANGED, () => {
|
||||
eventBus.on(CoreEvents.WORKWEEK_CHANGED, () => {
|
||||
this.render();
|
||||
})
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue