UNPKG

saltfish

Version:

An interactive video-guided tour system for web applications

63 lines 2.01 kB
/** * Observer Pattern implementation * * This file implements the Observer pattern to decouple state changes from UI updates. * It provides a generic Subject and Observer interface that can be used throughout * the application. */ /** * Observable Subject interface * Represents an object that can be observed by multiple observers. */ export interface Subject<T> { /** * Register an observer to receive notifications * @param observer The observer to register */ addObserver(observer: Observer<T>): void; /** * Remove an observer to stop receiving notifications * @param observer The observer to remove * @returns true if the observer was found and removed, false otherwise */ removeObserver(observer: Observer<T>): boolean; /** * Notify all observers about a state change * @param data The data to pass to observers */ notifyObservers(data: T): void; } /** * Observer interface * Represents an object that wants to be notified of changes in a Subject. */ export interface Observer<T> { /** * Handle a state change notification from a subject * @param data The data passed from the subject */ update(data: T): void; } /** * Abstract Subject class that implements the core Subject functionality */ export declare abstract class AbstractSubject<T> implements Subject<T> { private observers; /** * Register an observer to receive notifications * @param observer The observer to register */ addObserver(observer: Observer<T>): void; /** * Remove an observer to stop receiving notifications * @param observer The observer to remove * @returns true if the observer was found and removed, false otherwise */ removeObserver(observer: Observer<T>): boolean; /** * Notify all observers about a state change * @param data The data to pass to observers */ notifyObservers(data: T): void; } //# sourceMappingURL=Observer.d.ts.map