A channel is the basic building block of Realtime and narrows the scope of data flow to subscribed clients. You can think of a channel as a chatroom where participants are able to see who's online and send and receive messages.

Hierarchy

  • RealtimeChannel

Constructors

Properties

bindings: {
    [key: string]: {
        callback: Function;
        filter: {
            [key: string]: any;
        };
        id?: string;
        type: string;
    }[];
}

Type declaration

  • [key: string]: {
        callback: Function;
        filter: {
            [key: string]: any;
        };
        id?: string;
        type: string;
    }[]
broadcastEndpointURL: string
joinPush: default
joinedOnce: boolean
private: boolean
pushBuffer: default[]
rejoinTimer: default
state: CHANNEL_STATES
subTopic: string
timeout: number
topic: string

Topic name can be any string.

Methods

  • Type Parameters

    • T extends {
          [key: string]: any;
      } = {}

    Returns RealtimePresenceState<T>

  • Sends a message into the channel.

    Parameters

    • args: {
          event: string;
          payload?: any;
          type: "presence" | "postgres_changes" | "broadcast";
          [key: string]: any;
      }

      Arguments to send to channel

      • [key: string]: any
      • event: string

        The name of the event being sent

      • Optional payload?: any

        Payload to be sent

      • type: "presence" | "postgres_changes" | "broadcast"

        The type of event to send

    • Optional opts: {
          [key: string]: any;
      }

      Options to be used during the send process

      • [key: string]: any

    Returns Promise<RealtimeChannelSendResponse>

  • Teardown the channel.

    Destroys and stops related timers.

    Returns void

  • Parameters

    • payload: {
          [key: string]: any;
      }
      • [key: string]: any
    • Optional opts: {
          [key: string]: any;
      }
      • [key: string]: any

    Returns Promise<RealtimeChannelSendResponse>

  • Leaves the channel.

    Unsubscribes from server events, and instructs channel to terminate on server. Triggers onClose() hooks.

    To receive leave acknowledgements, use the a receive hook to bind to the server ack, ie: channel.unsubscribe().receive("ok", () => alert("left!") )

    Parameters

    • Optional timeout: number

    Returns Promise<"error" | "ok" | "timed out">

  • Parameters

    • Optional opts: {
          [key: string]: any;
      }
      • [key: string]: any

    Returns Promise<RealtimeChannelSendResponse>

  • Parameters

    • payload: {
          [key: string]: any;
      }
      • [key: string]: any

    Returns void

Generated using TypeDoc