mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
I've added JSDoc comments to interface hooks and utils.
This change introduces JSDoc-style comments to several TypeScript files within your `src/interface` directory to improve code understanding and maintainability, focusing on hooks and utility functions. - `src/interface/hooks/BackgroundDataLoader.ts`: I added comments to all exported functions and the `BackgroundDB` interface, detailing IndexedDB interactions for background image storage. - `src/interface/hooks/SettingsPopup.ts`: I documented the public methods of the `SettingsPopup` singleton, which handles event notifications for settings popup closures. - `src/interface/utils/themeImageHandlers.ts`: I added comments to all exported functions, explaining their roles in managing images within custom themes (uploading, removing, etc.). - `src/interface/hooks/BackgroundUpdates.ts`: I documented the `BackgroundUpdates` singleton class and its methods, used for broadcasting generic background update events. - `src/interface/hooks/ThemeUpdates.ts`: I documented the `ThemeUpdates` singleton class and its methods, responsible for broadcasting theme-related update events.
This commit is contained in:
@@ -1,11 +1,21 @@
|
||||
type BackgroundUpdateCallback = () => void;
|
||||
|
||||
/**
|
||||
* A singleton class used to notify listeners about generic background updates or events.
|
||||
* These updates typically signify that UI components or other parts of the application
|
||||
* might need to refresh or re-evaluate background-related data (e.g., after a new background
|
||||
* image is added, removed, or changed).
|
||||
*/
|
||||
class BackgroundUpdates {
|
||||
private static instance: BackgroundUpdates;
|
||||
private listeners: Set<BackgroundUpdateCallback> = new Set();
|
||||
|
||||
private constructor() {}
|
||||
|
||||
/**
|
||||
* Gets the singleton instance of the BackgroundUpdates class.
|
||||
* @returns {BackgroundUpdates} The singleton instance.
|
||||
*/
|
||||
public static getInstance(): BackgroundUpdates {
|
||||
if (!BackgroundUpdates.instance) {
|
||||
BackgroundUpdates.instance = new BackgroundUpdates();
|
||||
@@ -13,14 +23,31 @@ class BackgroundUpdates {
|
||||
return BackgroundUpdates.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a callback function to be invoked when a background update is triggered.
|
||||
*
|
||||
* @param {BackgroundUpdateCallback} callback The function to call when a background update occurs.
|
||||
* This callback takes no arguments and returns void.
|
||||
*/
|
||||
public addListener(callback: BackgroundUpdateCallback): void {
|
||||
this.listeners.add(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a previously added callback function.
|
||||
* After calling this method, the provided callback will no longer be invoked when a background update is triggered.
|
||||
*
|
||||
* @param {BackgroundUpdateCallback} callback The callback function to remove from the listeners.
|
||||
*/
|
||||
public removeListener(callback: BackgroundUpdateCallback): void {
|
||||
this.listeners.delete(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes all registered listener callbacks, signifying that a background update has occurred.
|
||||
* This method should be called whenever a change to background data happens that requires
|
||||
* other parts of the application to be notified.
|
||||
*/
|
||||
public triggerUpdate(): void {
|
||||
this.listeners.forEach((callback) => callback());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user