import { type UIEvent } from '@devvit/protos/types/devvit/ui/events/v1alpha/event.js'; import type { JsonObject } from '@devvit/shared-types/json.js'; import type { ReactiveElement } from 'lit'; import type { DevvitUIEffectEvent } from '../dispatcher/events.js'; import { EffectHandler } from './effect-handler.js'; export type OnUIEvent = (ev: UIEvent) => void; /** * This class encapsulates as much code as possible for possible future play * usage and to avoid shreddit iteration loops. It is subclassed in shreddit * by ShredditRealtimeHandler. */ export declare abstract class RealtimeEffectHandler extends EffectHandler { #private; private readonly _channels; hostConnected(): void; hostDisconnected(): void; /** Create, if necessary, and connect to the channel socket. */ protected abstract onConnectSock(channel: string, onEvent: OnUIEvent | undefined): void; /** Disconnect the channel socket but don't free resources. */ protected abstract onDisconnectSock(channel: string): void; protected onEvent(ev: DevvitUIEffectEvent): void; /** Destroy the channel socket. */ protected abstract onFreeSock(channel: string): void; protected abstract onSendSock(channel: string, data: JsonObject): Promise; /** App called useChannel().send(). */ private _onSendEv; } export declare class DisabledRealtimeEffectHandler extends EffectHandler { constructor(host: ReactiveElement); protected onEvent(ev: DevvitUIEffectEvent): void; } /** * Converts a UIEvent.RealtimeSubscriptionEvent.channel to UIEvent.hook. Eg: * `snntest20240521a:4feabe7a-fe98-47fa-97b5-ebc03e126918:locations` becomes * `useChannel:locations`. Maintain compatiblity with useChannel(). */ export declare function realtimeChannelToHookID(channel: string): string; //# sourceMappingURL=realtime-effect-handler.d.ts.map