rwsdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
20 lines (19 loc) • 1.03 kB
TypeScript
import { type SyncedStateClient, type SyncedStateStatus, type StatusChangeCallback, type WebSocketFactory } from "./connection/types.js";
import { getBackoffMs } from "./reconnect/backoff.js";
export type { SyncedStateClient, SyncedStateStatus, StatusChangeCallback };
export declare const onStatusChange: (endpoint: string, callback: StatusChangeCallback) => (() => void);
/**
* Returns a cached client for the provided endpoint, creating it when necessary.
* The returned client is a thin wrapper around a raw WebSocket that speaks the
* JSON state-sync protocol.
*/
export declare const getSyncedStateClient: (endpoint?: string, webSocketFactory?: WebSocketFactory) => SyncedStateClient;
/**
* Resets all state for an endpoint. Used by tests to isolate test cases and
* by cleanup paths.
*/
export declare const setSyncedStateClientForTesting: (client: SyncedStateClient | null, endpoint?: string) => void;
export declare const __testing: {
getBackoffMs: typeof getBackoffMs;
PENDING_REQUEST_TIMEOUT_MS: number;
};