import type { ISPEventObserver } from './ISPEventObserver'; import type SPEventArgs from './SPEventArgs'; /** * Manager for the eventing system. * * Allows to register/unregister event handlers to events, and raises those events. * The events are identified by its name as a string, and it doesn't provide type safety for the event arguments. * * There are two types of events: regular and sticky. * Sticky events are events that once raised, every listener that subscribed to the event will be automatically * executed as if the event was raised. * Sticky events are useful for framework-level notification, like when a system is initialized (every listener will * know the system is initialized). * * This is an internal architecture underlying the SPEvent class, which provides a handy way to register and unregister * events, and provides the type safety. This class should not be exposed to third-parties directly. * * @internal */ export default class SPEventManager { private static _logSource; private static _instance; private _listeners; private _raisedEvents; /** * Instance of the SPEventManager. */ static get instance(): SPEventManager; constructor(); /** * Raises an event. * * After this is called, all components registered under the event will execute their callback. * @param eventName - Name of the event * @param eventArgs - Arguments of the event * @alpha */ raiseEvent(eventName: string, eventArgs: TEventArgs): void; /** * Raises a sticky event. * Sticky events are stored, so when new listeners are added to the event, they will be immediately notified. * * After this is called, all components registered under the event will execute their callback. * @param eventName - Name of the event * @param eventArgs - Arguments of the event * @alpha */ raiseStickyEvent(eventName: string, eventArgs: TEventArgs): void; /** * Registers an event handler for an event. * @param eventName - Name of the event to register to. * @param observer - Component that is registering the event. * @param eventHandler - Function to handle the event. */ registerEvent(eventName: string, observer: ISPEventObserver, eventHandler: (eventArgs: TEventArgs) => void): void; /** * Removes an event handler from the event listeners list. * The event handler passed as input must be the first one that was used to register to the event. * * @remarks * If this is requested without adding an event handler first, it logs an error. * * @param eventName - Name of the event to remove the event handler from. * @param observer - Component that is deregistering from the event. * @param eventHandler - Function to handle the event. Used to remove it from the list of listeners. */ unregisterEvent(eventName: string, observer: ISPEventObserver, eventHandler: (eventArgs: TEventArgs) => void): void; /** * Removes all information from an event from the Event Manager, including all listeners. * * @param eventName - Name of the event to remove. */ removeEvent(eventName: string): void; /** * Removes all information for all events whose id starts with the provided prefix from the Event Manager. * This removes all listeners for all events that match. * * @param eventNamePrefix - Prefix for the event names. */ removeEventsByPrefix(eventNamePrefix: string): void; /** * Returns the number of listeners for a particular event * * @internal */ _listenerCount(eventName: string): number; /** * * @param eventName - Name of the event to clear from the queue. */ _clearStickyEventQueue(eventName: string): void; /** * Private function to raise an event. * This include the shared functionality between raising sticky and regular events. * * After this is called, all components registered under the event will execute their callback. * @param eventName - Name of the event * @param eventArgs - Arguments of the event */ private _raiseEventInternal; } //# sourceMappingURL=SPEventManager.d.ts.map