Interface IEventEmitter<H, E>
Methods
emit
- emit<K>(event: K, ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): H
-
Type Parameters
-
K extends string | number | symbol
Parameters
-
event: K
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns H
emitAsync
- emitAsync<K>(event: K, ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): Promise<(Exclude<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> | (Extract<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> extends Promise<R> ? R : never))[]> & {
isResolved?: true;
}
-
Type Parameters
-
K extends string | number | symbol
Parameters
-
event: K
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns Promise<(Exclude<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> | (Extract<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> extends Promise<R> ? R : never))[]> & {
isResolved?: true;
}
emitAsyncParallel
- emitAsyncParallel<K>(event: K, ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): Promise<(Exclude<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> | (Extract<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> extends Promise<R> ? R : never))[]> & {
isResolved?: true;
}
-
Type Parameters
-
K extends string | number | symbol
Parameters
-
event: K
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns Promise<(Exclude<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> | (Extract<ReturnType<Extract<E[K], AnyFunction<any>>>, Promise<any>> extends Promise<R> ? R : never))[]> & {
isResolved?: true;
}
emitCollect
- emitCollect<K>(event: K, ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): ReturnType<Extract<E[K], AnyFunction<any>>>[]
-
Type Parameters
-
K extends string | number | symbol
Parameters
-
event: K
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns ReturnType<Extract<E[K], AnyFunction<any>>>[]
emitFirst
- emitFirst<K>(event: K, ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): undefined | UndefinedFromVoid<ReturnType<Extract<E[K], AnyFunction<any>>>>
-
Type Parameters
-
K extends string | number | symbol
Parameters
-
event: K
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns undefined | UndefinedFromVoid<ReturnType<Extract<E[K], AnyFunction<any>>>>
emitFirstDefault
- emitFirstDefault<K, D>(event: K, generateDefault: (() => D), ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): D | Exclude<ReturnType<Extract<E[K], AnyFunction<any>>>, undefined | null>
-
Type Parameters
-
K extends string | number | symbol
-
D
Parameters
-
event: K
-
generateDefault: (() => D)
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns D | Exclude<ReturnType<Extract<E[K], AnyFunction<any>>>, undefined | null>
emitReduce
- emitReduce<K, A>(event: K, arg: A, ...args: Tail<Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>>): Extract<ReturnType<Extract<E[K], AnyFunction<any>>> & Head<Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>>, undefined> extends undefined ? undefined extends A ? ReturnType<Extract<E[K], AnyFunction<any>>> : A : ReturnType<Extract<E[K], AnyFunction<any>>>
-
Type Parameters
-
K extends string | number | symbol
-
A extends any
Parameters
-
event: K
-
arg: A
-
Rest
...args: Tail<Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>>
Returns Extract<ReturnType<Extract<E[K], AnyFunction<any>>> & Head<Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>>, undefined> extends undefined ? undefined extends A ? ReturnType<Extract<E[K], AnyFunction<any>>> : A : ReturnType<Extract<E[K], AnyFunction<any>>>
emitSelf
- emitSelf<K>(event: K, ...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>): H
-
Type Parameters
-
K extends string | number | symbol
Parameters
-
event: K
-
Rest
...args: Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<E[K], AnyFunction<any>>, AnyFunction<any>>>>, any[]>
Returns H
hasHandlersForEvent
- hasHandlersForEvent(...events: (keyof E)[]): boolean
-
Parameters
-
Rest
...events: (keyof E)[]
Returns boolean
subscribe
- subscribe<K>(event: K, handler: IterableOr<Handler<H, K extends any[] ? E[K[number]] : E[Extract<K, keyof E>]>>, priority?: number): H
-
Type Parameters
-
K extends string | number | symbol | (keyof E)[]
Parameters
-
event: K
-
handler: IterableOr<Handler<H, K extends any[] ? E[K[number]] : E[Extract<K, keyof E>]>>
-
Optional
priority: number
Returns H
unsubscribe
- unsubscribe<K>(event: K, handler: IterableOr<Handler<H, K extends any[] ? E[K[number]] : E[Extract<K, keyof E>]>>, priority?: number): boolean
-
Type Parameters
-
K extends string | number | symbol | (keyof E)[]
Parameters
-
event: K
-
handler: IterableOr<Handler<H, K extends any[] ? E[K[number]] : E[Extract<K, keyof E>]>>
-
Optional
priority: number
Returns boolean
until
- until<E2>(emitter: IEventEmitterHost<E2>, ...events: (keyof E2)[]): IUntilSubscriber<H, E>
-
Parameters
-
-
Rest
...events: (keyof E2)[]
- until(promise: Promise<any>): IUntilSubscriber<H, E>
-
waitFor
- waitFor<K>(events: K, priority?: number): Promise<Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<K extends any[] ? E[K[number]] : E[Extract<K, keyof E>], AnyFunction<any>>, AnyFunction<any>>>>, any[]>>
-
Type Parameters
-
K extends string | number | symbol | (keyof E)[]
Parameters
-
events: K
-
Optional
priority: number
Returns Promise<Extract<LiterallyJustTheSameThing<Parameters<Extract<Extract<K extends any[] ? E[K[number]] : E[Extract<K, keyof E>], AnyFunction<any>>, AnyFunction<any>>>>, any[]>>
Emit an event only to the subscribers of this emitter instance.