diff --git a/packages/events/src/events.ts b/packages/events/src/events.ts index 907cbf24d..c1ac796cc 100644 --- a/packages/events/src/events.ts +++ b/packages/events/src/events.ts @@ -5,14 +5,10 @@ export interface Event { } /** - * Emitter typecasts for a single event type + * Emitter typecasts for a single event type. */ export class Emitter { - private listeners: Array<(e: T) => void> | undefined; - - public constructor() { - this.listeners = []; - } + private listeners = void>>[]; public get event(): Event { return (cb: (e: T) => void): IDisposable => { @@ -34,7 +30,7 @@ export class Emitter { } /** - * Emit a value + * Emit an event with a value. */ public emit(value: T): void { if (this.listeners) { @@ -43,16 +39,9 @@ export class Emitter { } /** - * Disposes the event emitter + * Dispose the current events. */ public dispose(): void { - this.listeners = undefined; - } - - /** - * Whether the event has listeners. - */ - public get hasListeners(): boolean { - return !!this.listeners && this.listeners.length > 0; + this.listeners = []; } }