import * as Ably from '@ably/pubsub-core'; /** * This type represents a callback that can be registered with an EventEmitter. * * The EventsMap is an interface of event names to the types of the payloads of * those events. For example: * * interface MyEvents { * reaction: {emoji: string} * } * * There is no need to use this type directly, it is used for defining the * InterfaceEventEmitter. */ type Callback = (arg: EventsMap[keyof EventsMap]) => void; type CallbackSingle = (arg: K) => void; /** * This interface narrows the emit, on and off methods of the Pub/Sub * {@link Ably.EventEmitter} to the events and payloads of an EventsMap. */ interface InterfaceEventEmitter extends Omit { emit(event: K, arg: EventsMap[K]): void; on(event: K, callback: CallbackSingle): void; on(events: [K1, K2], callback: CallbackSingle): void; on(events: [K1, K2, K3], callback: CallbackSingle): void; on(events: (keyof EventsMap)[], callback: Callback): void; on(callback: Callback): void; off(event: K, listener: CallbackSingle): void; off(listener?: Callback): void; off(listener: CallbackSingle): void; } /** * The Pub/Sub {@link Ably.EventEmitter} constructor, typed to produce an * {@link InterfaceEventEmitter}. * * We do not export this directly because we prefer to export a class, which is * what we normally expect EventEmitter to be. */ declare const InternalEventEmitter: new () => InterfaceEventEmitter; /** * EventEmitter class based on the Pub/Sub {@link Ably.EventEmitter}. It is * different from the Pub/Sub EventEmitter because it takes an EventsMap type * parameter that types the events and their payloads. * * The EventsMap is an interface of event names to the types of the payloads of * those events. For example: * * interface MyEvents { * reaction: {emoji: string} * } * * There is no need to use this type directly, it is used for defining the * InterfaceEventEmitter. */ declare class EventEmitter extends InternalEventEmitter { } export default EventEmitter; /** * Creates a wrapper function that forwards all arguments to the provided function. * @param fn The function to wrap * @returns A new function with the same signature as the input function */ export declare const wrap: (fn: (...args: Args) => Return) => ((...args: Args) => Return); /** * Checks if an EventEmitter has any listeners registered. * @param emitter The EventEmitter instance to check * @returns true if the emitter has listeners, false otherwise */ export declare const emitterHasListeners: (emitter: EventEmitter) => boolean;