From 94f977845ae9b125e39d59419695ce664f275769 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Feb 2019 10:16:43 -0600 Subject: [PATCH] Make event listeners never undefined, remove unused func --- packages/events/src/events.ts | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/packages/events/src/events.ts b/packages/events/src/events.ts index 907cbf24..c1ac796c 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 = []; } }