/** * Per-process registry of channel subscribers used by worker code that * needs to react to events broadcast via `websocketEventsHost.publish(...)` * without holding an actual websocket session. * * Each Velocious worker thread (and the in-process handler used in tests) * gets its own instance attached to the configuration via * `setWebsocketChannelSubscribers(...)`. */ export default class VelociousWebsocketChannelSubscribers { /** * Narrows the runtime value to the documented type. * @type {Map, meta: {channel: string, createdAt?: string, eventId?: string}) => void | Promise>>} */ _subscribers: Map, meta: { channel: string; createdAt?: string; eventId?: string; }) => void | Promise>>; constructor(); /** * Runs subscribe. * @param {string} channel - Channel name to subscribe to. * @param {(payload: ReturnType, meta: {channel: string, createdAt?: string, eventId?: string}) => void | Promise} callback - Callback invoked for each event on the channel. * @returns {() => void} - Unsubscribe function. */ subscribe(channel: string, callback: (payload: ReturnType, meta: { channel: string; createdAt?: string; eventId?: string; }) => void | Promise): () => void; /** * Runs unsubscribe. * @param {string} channel - Channel name. * @param {(payload: ReturnType, meta: {channel: string, createdAt?: string, eventId?: string}) => void | Promise} callback - Previously registered callback. * @returns {void} */ unsubscribe(channel: string, callback: (payload: ReturnType, meta: { channel: string; createdAt?: string; eventId?: string; }) => void | Promise): void; /** * Runs has subscribers. * @param {string} channel - Channel name. * @returns {boolean} - Whether any subscribers exist for the channel. */ hasSubscribers(channel: string): boolean; /** * Dispatch an event to all subscribers of the channel. * @param {object} args - Event args. * @param {string} args.channel - Channel name. * @param {ReturnType} args.payload - Event payload. * @param {string} [args.createdAt] - Event creation time. * @param {string} [args.eventId] - Event identifier. * @returns {Promise} - Resolves when all subscribers have completed. */ dispatch({ channel, payload, createdAt, eventId }: { channel: string; payload: ReturnType; createdAt?: string; eventId?: string; }): Promise; } //# sourceMappingURL=websocket-channel-subscribers.d.ts.map