export type ConnectedHandler = () => Promise; export type DisconnectedHandler = () => Promise; /** * Represents the lifecycle state for a Chronicle connection. */ export declare class ConnectionLifecycle { private readonly _onConnected; private readonly _onDisconnected; private readonly _onFailed; private _failure?; private _isConnected; private _connectionId; /** * Gets whether the connection is currently connected. */ get isConnected(): boolean; /** Gets the terminal connection failure, if recovery has stopped. */ get failure(): Error | undefined; /** * Gets the current connection identifier. */ get connectionId(): string; /** * Registers a callback for when the connection is connected. * @param handler - Callback to invoke on connect. * @returns A function that unsubscribes the callback. */ onConnected(handler: ConnectedHandler): () => void; /** * Registers a callback for when the connection is disconnected. * @param handler - Callback to invoke on disconnect. * @returns A function that unsubscribes the callback. */ onDisconnected(handler: DisconnectedHandler): () => void; /** Registers a callback for a terminal connection failure. */ onFailed(handler: (error: Error) => Promise): () => void; /** Stops recovery and notifies observers of the terminal connection failure. */ failed(error: Error, onError: (error: unknown) => void): Promise; /** * Marks lifecycle as connected and invokes connected handlers. */ connected(onError: (error: unknown) => void): Promise; /** * Marks lifecycle as disconnected and invokes disconnected handlers. */ disconnected(onError: (error: unknown) => void): Promise; private invokeHandler; } //# sourceMappingURL=ConnectionLifecycle.d.ts.map