Skip to content

Commit

Permalink
fix: add all EventListener methods to TypedEventEmitter interface (
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCalzone authored Oct 20, 2023
1 parent ed948ae commit 7d35f0a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/shared/src/EventEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export interface TypedEventEmitter<
event: TEvent,
callback: TEvents[TEvent],
): this;
prependListener<TEvent extends keyof TEvents>(
event: TEvent,
callback: TEvents[TEvent],
): this;
prependOnceListener<TEvent extends keyof TEvents>(
event: TEvent,
callback: TEvents[TEvent],
): this;

removeListener<TEvent extends keyof TEvents>(
event: TEvent,
callback: TEvents[TEvent],
Expand All @@ -57,12 +66,29 @@ export interface TypedEventEmitter<
event: TEvent,
callback: TEvents[TEvent],
): this;

removeAllListeners(event?: keyof TEvents): this;

emit<TEvent extends keyof TEvents>(
event: TEvent,
...args: Parameters<TEvents[TEvent]>
): boolean;

setMaxListeners(n: number): this;
getMaxListeners(): number;

listeners<TEvent extends keyof TEvents>(
eventName: TEvent,
): TEvents[TEvent][];
rawListeners<TEvent extends keyof TEvents>(
eventName: TEvent,
): TEvents[TEvent][];
listenerCount<TEvent extends keyof TEvents>(
event: TEvent,
listener?: TEvents[TEvent],
): number;

eventNames(): Array<keyof TEvents>;
}

export class TypedEventEmitter<
Expand Down

0 comments on commit 7d35f0a

Please sign in to comment.