import type { Channel as PhoenixChannel, Socket } from "phoenix"; import { type Unsubscriber, type Writable } from "svelte/store"; export type EventName = string; export type HandlerRef = number; export declare class Channel { topic: string; channelJoinLeaveTimeout?: number; /** * Stores current socket, that this channel joins from */ socket: Socket | null | undefined; channel: Writable; channelEventHandlers: [EventName, HandlerRef][]; loading: boolean; /** * number of subscribers */ channelSubscribersCount: number; channelSubscribersCountDebounced: (count: 1 | -1) => void; unsubscribeSocket: Unsubscriber; unsubscribeChannelSubscribers: any; joined: boolean; /** * @param socket Socket * @param topic Topic * @param params Params * @param timeout Use for both join and leave messages of channel */ constructor(socket: Writable, topic: string, params?: object, timeout?: number); pushAsync(type: string, payload?: {}, timeout?: number): Promise; /** * Called internally */ socketChangedAsync(socket: Socket | null, topic: string, params: object): Promise; join(): Promise; leave(): void; private joinChannelAsync; private leaveChannelAsync; subscribeHandlerAsync(event: string, handler: (response: any) => void): Promise; unsubscribeHandlerAsync(event: string, reference: number): Promise; getAsync(): Promise; waitForChannelJoinedAsync(): Promise; waitForChannelAsync(): Promise; updateChannelSubscribersCountAsync(stepCommits: number[][]): Promise; destroyAsync(): Promise; } /** * Generic push */ export declare function pushSocketMessageAsync(channel: PhoenixChannel, type: string, payload?: object, timeout?: number): Promise; export type PushResponse = { data: TData; }; /** * This is specifically for our specific return data structure * (TData has to be in data property). * It writes error to console and throws exceptions * @param channel * @param event * @param payload * @param pushTimeout - timeout for push, if it is <= 0 then it is ignored * @param channelTimeout */ export declare function savePushAsync(channel: Channel, event: string, payload: any, pushTimeout?: number, channelTimeout?: number): Promise;