diff --git a/ably.d.ts b/ably.d.ts index 4513f94c3..d26a4807f 100644 --- a/ably.d.ts +++ b/ably.d.ts @@ -2040,6 +2040,27 @@ export declare interface RealtimePresence { */ unsubscribe(): void; + /** + * Returns all listeners currently registered on this presence object. + * + * @returns An array of listener functions for all events. Returns an empty array if no listeners are found. + */ + listeners(): Function[]; + /** + * Returns the listeners for a specified presence action on this presence object. + * + * @param event - The presence action name to retrieve the listeners for. + * @returns An array of listener functions for the specified event. Returns an empty array if no listeners are found. + */ + listeners(event: string): Function[]; + /** + * Returns the listeners for multiple specified presence actions on this presence object. + * + * @param events - An array of presence action names to retrieve the listeners for. + * @returns An array of listener functions for all the specified events combined. Returns an empty array if no listeners are found. + */ + listeners(events: string[]): Function[]; + /** * Retrieves the current members present on the channel and the metadata for each member, such as their {@link PresenceAction} and ID. Returns an array of {@link PresenceMessage} objects. * @@ -2934,6 +2955,27 @@ export declare interface RealtimeChannel extends EventEmitter { + const listeners = this.listeners(eventName); + if (listeners) { + allListeners.push(...listeners); + } + }); + return allListeners.length ? allListeners : null; + } + if (event) { const listeners = this.events[event] || []; if (this.eventsOnce[event]) Array.prototype.push.apply(listeners, this.eventsOnce[event]);