WebSocket Client Options (wsClient/options.ts)

trpc · packages/client/src/links/wsLink/wsClient/options.ts · typescript · MIT
realtime, infra, fw:trpc

Defines configuration and lifecycle hooks for WebSocket connections, including retry logic. Use this to manage persistent real-time communication channels.

// Source: https://github.com/trpc/trpc | License: MIT | Copyright 2023 Alex Johansson
// Provided via justclaw.it.com; keep this notice with the code.
import type { UrlOptionsWithConnectionParams } from '../../internals/urlWithConnectionParams';
import type { Encoder } from './encoder';

export interface WebSocketClientOptions extends UrlOptionsWithConnectionParams {
  /**
   * Ponyfill which WebSocket implementation to use
   */
  WebSocket?: typeof WebSocket;
  /**
   * The number of milliseconds before a reconnect is attempted.
   * @default {@link exponentialBackoff}
   */
  retryDelayMs?: (attemptIndex: number) => number;
  /**
   * Triggered when a WebSocket connection is established
   */
  onOpen?: () => void;
  /**
   * Triggered when a WebSocket connection encounters an error
  

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key