Refactors calendar initialization with factory
Implements a factory pattern for manager creation and initialization, improving dependency management and extensibility. This change replaces direct manager instantiation with a `ManagerFactory` that handles dependency injection. This enhances code organization and testability. It also includes an initialization sequence diagram for better understanding of the calendar's architecture and data flow.
This commit is contained in:
parent
32ee35eb02
commit
26f0cb8aaa
11 changed files with 333 additions and 150 deletions
53
src/interfaces/IManager.ts
Normal file
53
src/interfaces/IManager.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/**
|
||||
* Base interface for all managers
|
||||
*/
|
||||
export interface IManager {
|
||||
/**
|
||||
* Initialize the manager
|
||||
*/
|
||||
initialize?(): Promise<void> | void;
|
||||
|
||||
/**
|
||||
* Refresh the manager's state
|
||||
*/
|
||||
refresh?(): void;
|
||||
|
||||
/**
|
||||
* Destroy the manager and clean up resources
|
||||
*/
|
||||
destroy?(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for managers that handle events
|
||||
*/
|
||||
export interface IEventManager extends IManager {
|
||||
loadData(): Promise<void>;
|
||||
getEvents(): any[];
|
||||
getEventsForPeriod(startDate: Date, endDate: Date): any[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for managers that handle rendering
|
||||
*/
|
||||
export interface IRenderingManager extends IManager {
|
||||
render(): Promise<void> | void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for managers that handle navigation
|
||||
*/
|
||||
export interface INavigationManager extends IManager {
|
||||
getCurrentWeek(): Date;
|
||||
navigateToToday(): void;
|
||||
navigateToNextWeek(): void;
|
||||
navigateToPreviousWeek(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for managers that handle scrolling
|
||||
*/
|
||||
export interface IScrollManager extends IManager {
|
||||
scrollTo(scrollTop: number): void;
|
||||
scrollToHour(hour: number): void;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue