UNPKG

@zowe/imperative

Version:
99 lines 4.35 kB
import { IEmitter, IEmitterAndWatcher, IWatcher } from "./doc/IEventInstanceTypes"; import { Logger } from "../../logger"; /** * ## Overview * The `EventOperator` manages event processors and sets limits on their behavior. * * An `EventOperator` categorizes processors into 3 types: * - **Watcher**: Listens for events and triggers callbacks when events occur. * - **Emitter**: Emits events that other applications listen for. * - **EmitterAndWatcher**: Combines the functionalities of both watcher and emitter. * * Applications use the `EventOperator` to obtain the appropriate event processor based on their needs. * For example, an application might use a watcher to react to user actions and an emitter to notify other * components of state changes. * * ### App Names and Processors * Processors are tied to application names to prevent event collisions and to maintain a clear separation * of event domains. Valid app names are defined in the list of extenders (formal plugin names or ZE extender names). * * ### Understanding Event Types * - **Predefined Zowe Events**: Zowe provides a set of predefined shared and user events that can be watched. * - **Custom Events**: Applications can define their own shared/user events, allowing for custom event-driven behavior. * * @export * @class EventOperator */ export declare class EventOperator { private static instances; /** * Creates an event processor for a specified application. * * @static * @param {string} appName - The name of the application. * @param {IProcessorTypes} type - The type of processor to create (emitter, watcher, or both). * @param {Logger} [logger] - Optional logger instance for the processor. * @returns {IZoweProcessor} A new or existing processor instance. * @throws {ImperativeError} If the application name is not recognized. */ private static createProcessor; /** * Retrieves a generic event processor that can emit and watch events. * * @static * @param {string} appName - The application name. * @param {Logger} [logger] - Optional logger for the processor. * @returns {IEmitterAndWatcher} An event processor capable of both emitting and watching. * @throws {ImperativeError} If the application name is not recognized. */ static getProcessor(appName: string, logger?: Logger): IEmitterAndWatcher; /** * Retrieves a watcher-only event processor. * * @static * @param {string} appName - The application name, defaults to "Zowe" if not specified. * @param {Logger} [logger] - Optional logger for the processor. * @returns {IWatcher} A watcher-only event processor. * @throws {ImperativeError} If the application name is not recognized. */ static getWatcher(appName?: string, logger?: Logger): IWatcher; /** * Retrieves an emitter-only event processor. * * @static * @param {string} appName - The application name. * @param {Logger} [logger] - Optional logger for the processor. * @returns {IEmitter} An emitter-only event processor. * @throws {ImperativeError} If the application name is not recognized. */ static getEmitter(appName: string, logger?: Logger): IEmitter; /** * Deletes a specific type of event processor (emitter). * * @static * @param {string} appName - The application name associated with the emitter to be deleted. */ static deleteEmitter(appName: string): void; /** * Deletes a specific type of event processor (watcher). * * @static * @param {string} appName - The application name associated with the watcher to be deleted. */ static deleteWatcher(appName: string): void; /** * Deletes an event processor, removing both its emitter and watcher capabilities. * * @static * @param {string} appName - The application name whose processor is to be deleted. */ static deleteProcessor(appName: string): void; /** * Destroys a processor by removing all associated file watchers and cleaning up resources. * * @static * @param {string} appName - The name of the application whose processor needs to be destroyed. */ private static destroyProcessor; } //# sourceMappingURL=EventOperator.d.ts.map