mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
chore: use descriptive type parameter names (#9937)
* chore: use descriptive type parameter names * refactor: requested changes --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -75,7 +75,7 @@ export interface IPubSubBroker<TEvents extends Record<string, any>>
|
||||
/**
|
||||
* Publishes an event
|
||||
*/
|
||||
publish<T extends keyof TEvents>(event: T, data: TEvents[T]): Promise<void>;
|
||||
publish<Event extends keyof TEvents>(event: Event, data: TEvents[Event]): Promise<void>;
|
||||
}
|
||||
|
||||
export interface IRPCBroker<TEvents extends Record<string, any>, TResponses extends Record<keyof TEvents, any>>
|
||||
@@ -84,5 +84,9 @@ export interface IRPCBroker<TEvents extends Record<string, any>, TResponses exte
|
||||
/**
|
||||
* Makes an RPC call
|
||||
*/
|
||||
call<T extends keyof TEvents>(event: T, data: TEvents[T], timeoutDuration?: number): Promise<TResponses[T]>;
|
||||
call<Event extends keyof TEvents>(
|
||||
event: Event,
|
||||
data: TEvents[Event],
|
||||
timeoutDuration?: number,
|
||||
): Promise<TResponses[Event]>;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export class PubSubRedisBroker<TEvents extends Record<string, any>>
|
||||
/**
|
||||
* {@inheritDoc IPubSubBroker.publish}
|
||||
*/
|
||||
public async publish<T extends keyof TEvents>(event: T, data: TEvents[T]): Promise<void> {
|
||||
public async publish<Event extends keyof TEvents>(event: Event, data: TEvents[Event]): Promise<void> {
|
||||
await this.options.redisClient.xadd(
|
||||
event as string,
|
||||
'*',
|
||||
|
||||
@@ -83,11 +83,11 @@ export class RPCRedisBroker<TEvents extends Record<string, any>, TResponses exte
|
||||
/**
|
||||
* {@inheritDoc IRPCBroker.call}
|
||||
*/
|
||||
public async call<T extends keyof TEvents>(
|
||||
event: T,
|
||||
data: TEvents[T],
|
||||
public async call<Event extends keyof TEvents>(
|
||||
event: Event,
|
||||
data: TEvents[Event],
|
||||
timeoutDuration: number = this.options.timeout,
|
||||
): Promise<TResponses[T]> {
|
||||
): Promise<TResponses[Event]> {
|
||||
const id = await this.options.redisClient.xadd(
|
||||
event as string,
|
||||
'*',
|
||||
@@ -103,7 +103,7 @@ export class RPCRedisBroker<TEvents extends Record<string, any>, TResponses exte
|
||||
const timedOut = new Error(`timed out after ${timeoutDuration}ms`);
|
||||
|
||||
await this.streamReadClient.subscribe(rpcChannel);
|
||||
return new Promise<TResponses[T]>((resolve, reject) => {
|
||||
return new Promise<TResponses[Event]>((resolve, reject) => {
|
||||
const timeout = setTimeout(() => reject(timedOut), timeoutDuration).unref();
|
||||
|
||||
this.promises.set(id!, { resolve, reject, timeout });
|
||||
|
||||
Reference in New Issue
Block a user