UNPKG

@donation-alerts/events

Version:
49 lines 1.68 kB
import { type CentrifugoChannel } from '@donation-alerts/common'; import { type Subscription } from 'centrifuge'; import { type UserEventsClient } from './user-events-client'; /** * Listener for subscription-based events in Centrifugo channels. * * @remarks * This class represents a connection to a specific Centrifugo channel associated with a user. * It handles event subscriptions and provides information about the connected channel and user. * You can use it to manage events and to remove the associated listener when it's no longer needed. * * @example * ```ts * console.log(listener.channel); // Full channel name * console.log(listener.userId); // User's ID * * await listener.remove(); // Removes the listener * ``` */ export declare class EventsListener { private readonly _channelName; private readonly _userId; private readonly _centrifugoSubscription; private readonly _client; /** @internal */ constructor(channelName: CentrifugoChannel, userId: number, subscription: Subscription, client: UserEventsClient); /** * ID of the user associated with this listener. */ get userId(): number; /** * Name of the Centrifugo channel associated with this listener. */ get channelName(): string; /** * Full name of the Centrifugo channel. * * @remarks * Combines the base channel name and the user ID to construct the complete channel string. */ get channel(): string; /** @internal */ get _subscription(): Subscription; /** * Removes this listener from the client. */ remove(): Promise<void>; } //# sourceMappingURL=events-listener.d.ts.map