Classcorev0.14.0
abstract class Subscriber<
Keys extends SubscriptionKey,
TCore extends CoreBase
>Member visibility
Filter class members by access level.
Subscriber(payload: AllSubscriptions[Keys], core: TCore, key: Keys)Keys
One or more subscription keys, like 'userJoin' or 'userJoin' | 'userLeave'.
Keys extends SubscriptionKeyTCore
The transport's Core
TCore extends CoreBaseprotected readonly core: TCoreprotected data: SingleKeyData<Keys>protected readonly key: Keysprotected readonly logger: Loggerprotected async match<Ret, Cases>(
cases: OnlyCases<Cases, SubscriberMatchCases<Keys, Ret>>
): Promise<MatchResult<Ret, Cases>>Type parameter:
RetThe type that every case must return. Leave it out to get the union of what the cases return.
Throws:
A SeedcordTypeError with MatchCaseMissing when the published key doesn't have a case.
import { Subscribe, Subscriber } from '@seedcord/gateway';
\@Subscribe(['interactionDispatched'], ['eventDispatched'])
class Metrics extends Subscriber<'interactionDispatched' | 'eventDispatched'> {
async execute() {
await this.match({
interactionDispatched: (data) => this.logger.info(data.routeId),
eventDispatched: (data) => this.logger.info(data.name)
});
}
}