Stone.js API
    Preparing search index...

    The isomorphic realtime client.

    The same Broadcaster API the backend uses, aimed at a server: broadcast/to().emit send an event up the socket, on subscribes a local listener to incoming events. Runs in the browser (global WebSocket) and on Node (lazy optional ws), so the domain code that emits and listens is written once and the transport is resolved by the context.

    Implements

    Index
    name: string = 'client'

    A human-readable name (e.g. 'memory', 'redis').

    • get connected(): boolean

      Whether the socket is open.

      Returns boolean

      True once connected.

    • Type Parameters

      • T = unknown

      Parameters

      • channel: string
      • event: string
      • Optionalpayload: T

      Returns Promise<void>

    • Close the connection.

      Returns void

    • Open the connection (idempotent).

      Returns Promise<void>

      A promise that resolves once the socket is open.

    • Subscribe the connection to a channel on the server.

      Parameters

      • channel: string

        The channel.

      Returns Promise<void>

    • Parameters

      • channel: string

      Returns { emit: <T = unknown>(event: string, payload?: T) => Promise<void> }

    • Unsubscribe the connection from a channel on the server.

      Parameters

      • channel: string

        The channel.

      Returns Promise<void>