import { StreamPartID } from '@streamr/protocol'; import { MessageStream } from './MessageStream'; /** * Events emitted by {@link Subscription}. */ export interface SubscriptionEvents { /** * Emitted if an error occurred in the subscription. */ error: (err: Error) => void; /** * Emitted when a resend is complete. */ resendComplete: () => void; } /** * A convenience API for managing an individual subscription. * * @category Important */ export declare class Subscription extends MessageStream { readonly streamPartId: StreamPartID; private readonly eventEmitter; private readonly logger; /** * Unsubscribes this subscription. * * @remarks The instance should not be used after calling this. */ unsubscribe(): Promise; /** * Adds an event listener to the subscription. * @param eventName - event name, see {@link SubscriptionEvents} for options * @param listener - the callback function */ on(eventName: E, listener: SubscriptionEvents[E]): void; /** * Adds an event listener to the subscription that is invoked only once. * @param eventName - event name, see {@link SubscriptionEvents} for options * @param listener - the callback function */ once(eventName: E, listener: SubscriptionEvents[E]): void; /** * Removes an event listener from the subscription. * @param eventName - event name, see {@link SubscriptionEvents} for options * @param listener - the callback function to remove */ off(eventName: E, listener: SubscriptionEvents[E]): void; }