mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 19:54:39 +00:00
30 lines
782 B
TypeScript
30 lines
782 B
TypeScript
type BackgroundUpdateCallback = () => void;
|
|
|
|
class BackgroundUpdates {
|
|
private static instance: BackgroundUpdates;
|
|
private listeners: Set<BackgroundUpdateCallback> = new Set();
|
|
|
|
private constructor() {}
|
|
|
|
public static getInstance(): BackgroundUpdates {
|
|
if (!BackgroundUpdates.instance) {
|
|
BackgroundUpdates.instance = new BackgroundUpdates();
|
|
}
|
|
return BackgroundUpdates.instance;
|
|
}
|
|
|
|
public addListener(callback: BackgroundUpdateCallback): void {
|
|
this.listeners.add(callback);
|
|
}
|
|
|
|
public removeListener(callback: BackgroundUpdateCallback): void {
|
|
this.listeners.delete(callback);
|
|
}
|
|
|
|
public triggerUpdate(): void {
|
|
this.listeners.forEach(callback => callback());
|
|
}
|
|
}
|
|
|
|
export const backgroundUpdates = BackgroundUpdates.getInstance();
|