UNPKG

@ima/core

Version:

IMA.js framework for isomorphic javascript application

61 lines 2.34 kB
import { Dispatcher, DispatcherEventsMap, DispatcherListener } from './Dispatcher'; import { Observable } from './Observable'; import { Settings } from '../boot'; import { Dependencies } from '../oc/ObjectContainer'; /** * An Observable is a class that manages event listeners and allows distributing * events to the registered listeners. It maintains a history of events and supports * persistent events that are not cleared during route changes. * * @remarks * - The Observable class relies on a Dispatcher to handle the actual event distribution. * - It maintains a history of events, which can be limited by a maximum history length. */ export declare class ObservableImpl extends Observable { protected _dispatcher: Dispatcher; protected _observers: Map<string, Map<DispatcherListener<any>, Set<unknown>>>; protected _activityHistory: Map<string, unknown[]>; protected _persistentEvents: Set<string>; protected _settings: Settings['$Observable']; static $dependencies: Dependencies; /** * Creates an instance of Observable. * * @param dispatcher - The dispatcher responsible for managing event listeners. * @param settings - Optional settings for the Observable instance. */ constructor(dispatcher: Dispatcher, settings?: Settings['$Observable']); /** * @inheritDoc */ init(): this; /** * @inheritDoc */ destroy(): this; /** * @inheritDoc */ clear(): this; /** * @inheritDoc */ registerPersistenEvent(event: keyof DispatcherEventsMap | string): this; /** * @inheritDoc */ subscribe(event: keyof DispatcherEventsMap | string, observer: DispatcherListener<any>, scope?: unknown): this; /** * @inheritDoc */ unsubscribe(event: keyof DispatcherEventsMap | string, observer: DispatcherListener<any>, scope?: unknown): this; /** * Handles dispatcher events by updating the activity history and notifying observers. * It also resets the activity history for non-persistent events on `BEFORE_HANDLE_ROUTE` ecvent. * * @param event - The name of the event being dispatched. * @param data - The data associated with the event. */ _handleDispatcherEvent(event: string, data: any): void; } //# sourceMappingURL=ObservableImpl.d.ts.map