## Overview

Each EventProcessor manages its own subscriptions, handling the addition, emission, and removal of events. It uses a map where event names are keys, and values are Event objects that hold detailed event information and subscriptions.

An `EventProcessor` handles three main functionalities:

- Subscribing to Events: Registration of a callback function that will be executed when that event occurs.
- Emitting Events: Notifying other applications or parts of the same application about certain actions or changes.
- Managing Event Subscriptions: Mapping subscribed events and their corresponding callbacks, ensuring that events are properly handled and dispatched.

### 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 and user events, allowing for custom event-driven behavior.

export

### Hierarchy

- EventProcessor

## Index

### Constructors

- constructor

### Properties

- appName
- eventTimes
- logger
- processorType
- subscribedEvents

### Methods

- _subscribe
- emit
- emitEvent
- emitZoweEvent
- subscribeShared
- subscribeUser
- unsubscribe

## Constructors

### constructor

- new EventProcessor(appName: string, type: IProcessorTypes, logger?: Logger): EventProcessor

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:50

  Constructor initializes a new instance of EventProcessor.

  throws

    {ImperativeError} If the application name is not recognized.

  #### Parameters

  - ##### appName: string

    The application's name.

  - ##### type: IProcessorTypes

    The type of processor (Emitter, Watcher, or Both).

  - ##### Optional logger: Logger

  #### Returns EventProcessor

## Properties

### appName

appName: string

- Defined in @zowe/imperative/src/events/src/EventProcessor.ts:49

### eventTimes

eventTimes: Map<string, string>

- Defined in @zowe/imperative/src/events/src/EventProcessor.ts:47

### logger

logger: Logger

- Defined in @zowe/imperative/src/events/src/EventProcessor.ts:50

### processorType

processorType: IProcessorTypes

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

### subscribedEvents

subscribedEvents: Map<string, Event> = new Map()

- Defined in @zowe/imperative/src/events/src/EventProcessor.ts:46

## Methods

### Private _subscribe

- _subscribe(type: "user" | "shared", eventName: string, callbacks: EventCallback[] | EventCallback): IEventDisposable

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:76

  #### Parameters

  - ##### type: "user" | "shared"

  - ##### eventName: string

  - ##### callbacks: EventCallback[] | EventCallback

  #### Returns IEventDisposable

### Private emit

- emit(eventName: string): void

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:122

  Private method to emit the event

  throws

    {ImperativeError} - If the event cannot be emitted.

  #### Parameters

  - ##### eventName: string

    Event to be emitted

  #### Returns void

### emitEvent

- emitEvent(eventName: string): void

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:140

  Emits an event by updating its timestamp and writing event data.

  throws

    {ImperativeError} If the processor does not have the correct permissions to perform this action.

  throws

    {ImperativeError} - If the event cannot be emitted.

  #### Parameters

  - ##### eventName: string

    The name of the event to emit.

  #### Returns void

### emitZoweEvent

- emitZoweEvent(eventName: string): void

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:158

  Specifically emits Zowe-related events, updating timestamps and handling data.

  internal

    Internal Zowe emitter method

  throws

    {ImperativeError} If the processor does not have the correct permissions to perform this action.

  throws

    {ImperativeError} - If the event cannot be emitted.

  #### Parameters

  - ##### eventName: string

    The name of the Zowe event to emit.

  #### Returns void

### subscribeShared

- subscribeShared(eventName: string, callbacks: EventCallback[] | EventCallback): IEventDisposable

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:100

  Subscription to an event that will notify all subscribed users.

  throws

    {ImperativeError} If the processor does not have the correct permissions to perform this action.

  #### Parameters

  - ##### eventName: string

    The name of the event to subscribe to.

  - ##### callbacks: EventCallback[] | EventCallback

    Callback functions to handle the event.

  #### Returns IEventDisposable

  - Object allowing management/cleanup of the subscription.

### subscribeUser

- subscribeUser(eventName: string, callbacks: EventCallback[] | EventCallback): IEventDisposable

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:112

  Subscription to an event that will notify a single user.

  throws

    {ImperativeError} If the processor does not have the correct permissions to perform this action.

  #### Parameters

  - ##### eventName: string

    The name of the event to subscribe to.

  - ##### callbacks: EventCallback[] | EventCallback

    Callback functions to handle the event.

  #### Returns IEventDisposable

  - Object allowing management/cleanup of the subscription.

### unsubscribe

- unsubscribe(eventName: string): void

- - Defined in @zowe/imperative/src/events/src/EventProcessor.ts:175

  Unsubscribes from an event, closing file watchers and cleaning up resources.

  throws

    {ImperativeError} If the processor does not have the correct permissions to perform this action.

  throws

    {ImperativeError} - If unsubscribing fails.

  #### Parameters

  - ##### eventName: string

    The name of the event to unsubscribe from.

  #### Returns void

Generated using TypeDoc