diff --git a/src/controls/EventDispatcher.ts b/src/controls/EventDispatcher.ts index 370c33b..0bdb2ff 100644 --- a/src/controls/EventDispatcher.ts +++ b/src/controls/EventDispatcher.ts @@ -36,10 +36,16 @@ export class EventDispatcher<TEventMap extends {} = {}> { * @param type The type of event to listen to. * @param listener The function that gets called when the event is fired. */ + addEventListener(type: string, listener: EventListener<{}, string, this>): void addEventListener<T extends Extract<keyof TEventMap, string>>( type: T, listener: EventListener<TEventMap[T], T, this>, - ): void { + ): void + addEventListener<T extends Extract<keyof TEventMap, string>>( + type: T | string, + listener: EventListener<TEventMap[T], T, this> | EventListener<{}, string, this>, + ): void + { if ( this._listeners === undefined ) this._listeners = {}; @@ -64,9 +70,14 @@ export class EventDispatcher<TEventMap extends {} = {}> { * @param type The type of event to listen to. * @param listener The function that gets called when the event is fired. */ + hasEventListener(type: string, listener: EventListener<{}, string, this>): boolean; hasEventListener<T extends Extract<keyof TEventMap, string>>( type: T, listener: EventListener<TEventMap[T], T, this>, + ): boolean; + hasEventListener<T extends Extract<keyof TEventMap, string>>( + type: T | string, + listener: EventListener<TEventMap[T], T, this> | EventListener<{}, string, this>, ): boolean { if ( this._listeners === undefined ) return false; @@ -82,9 +93,14 @@ export class EventDispatcher<TEventMap extends {} = {}> { * @param type The type of the listener that gets removed. * @param listener The listener function that gets removed. */ + removeEventListener(type: string, listener: EventListener<{}, string, this>): void; removeEventListener<T extends Extract<keyof TEventMap, string>>( type: T, listener: EventListener<TEventMap[T], T, this>, + ): void + removeEventListener<T extends Extract<keyof TEventMap, string>>( + type: T|string, + listener: EventListener<TEventMap[T], T, this> | EventListener<{}, string, this>, ): void { if ( this._listeners === undefined ) return; diff --git a/src/index.ts b/src/index.ts index 5f81f53..4206f09 100644 --- a/src/index.ts +++ b/src/index.ts @@ -65,6 +65,7 @@ export * from './math/ColorConverter' export * from './math/ImprovedNoise' export * from './math/Octree' export * from './math/Lut' +export * from './controls/EventDispatcher' export * from './controls/experimental/CameraControls' export * from './controls/FirstPersonControls' export * from './controls/TransformControls'