## 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

### Hierarchy

- EventOperator

## Index

### Properties

- instances

### Methods

- createProcessor
- deleteEmitter
- deleteProcessor
- deleteWatcher
- destroyProcessor
- getEmitter
- getProcessor
- getWatcher
- getZoweProcessor

## Properties

### Static Private instances

instances: Map<string, EventProcessor> = new Map()

- Defined in @zowe/imperative/src/events/src/EventOperator.ts:48

## Methods

### Static Private createProcessor

- createProcessor(appName: string, type: IProcessorTypes, logger?: Logger): IZoweProcessor

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:59

  Creates an event processor for a specified application.

  static
  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### appName: string

    The name of the application.

  - ##### type: IProcessorTypes

    The type of processor to create (emitter, watcher, or both).

  - ##### Optional logger: Logger

  #### Returns IZoweProcessor

  A new or existing processor instance.

### Static deleteEmitter

- deleteEmitter(appName: string): void

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:131

  Deletes a specific type of event processor (emitter).

  static

  #### Parameters

  - ##### appName: string

    The application name associated with the emitter to be deleted.

  #### Returns void

### Static deleteProcessor

- deleteProcessor(appName: string): void

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:151

  Deletes an event processor, removing both its emitter and watcher capabilities.

  static

  #### Parameters

  - ##### appName: string

    The application name whose processor is to be deleted.

  #### Returns void

### Static deleteWatcher

- deleteWatcher(appName: string): void

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:141

  Deletes a specific type of event processor (watcher).

  static

  #### Parameters

  - ##### appName: string

    The application name associated with the watcher to be deleted.

  #### Returns void

### Static Private destroyProcessor

- destroyProcessor(appName: string): void

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:161

  Destroys a processor by removing all associated file watchers and cleaning up resources.

  static

  #### Parameters

  - ##### appName: string

    The name of the application whose processor needs to be destroyed.

  #### Returns void

### Static getEmitter

- getEmitter(appName: string, logger?: Logger): IEmitter

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:121

  Retrieves an emitter-only event processor.

  static
  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### appName: string

    The application name.

  - ##### Optional logger: Logger

  #### Returns IEmitter

  An emitter-only event processor.

### Static getProcessor

- getProcessor(appName: string, logger?: Logger): IEmitterAndWatcher

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:95

  Retrieves a generic event processor that can emit and watch events.

  static
  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### appName: string

    The application name.

  - ##### Optional logger: Logger

  #### Returns IEmitterAndWatcher

  An event processor capable of both emitting and watching.

### Static getWatcher

- getWatcher(appName?: string, logger?: Logger): IWatcher

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:108

  Retrieves a watcher-only event processor.

  static
  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### Default value appName: string = "Zowe"

    The application name, defaults to "Zowe" if not specified.

  - ##### Optional logger: Logger

  #### Returns IWatcher

  A watcher-only event processor.

### Static getZoweProcessor

- getZoweProcessor(): IZoweProcessor

- - Defined in @zowe/imperative/src/events/src/EventOperator.ts:82

  Retrieves a Zowe-specific event processor. The purpose of this method is for internal Imperative APIs to get a properly initialized processor. This processor will be used when applications (like Zowe Explorer) call Imperative APIs that trigger events. For example, when the user updates credentials from Zowe Explorer, this processor could be used to emit an `OnVaultChanged` event.

  internal

    Not meant to be called by application developers

  static
  throws

    {ImperativeError} If the application name is not recognized.

  #### Returns IZoweProcessor

  The Zowe event processor instance.

Generated using TypeDoc