Options
All
  • Public
  • Public/Protected
  • All
Menu

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

Index

Constructors

Properties

bindings: {}

Type declaration

  • [key: string]: { callback: Function; filter: {}; 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

  • Creates an event handler that listens to changes.

    Parameters

    • type: "presence"
    • filter: { event: "sync" }
      • event: "sync"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    Returns RealtimeChannel

  • The following is placed here to display on supabase.com/docs/reference/javascript/subscribe.

    Parameters

    • type: "broadcast"

      One of "broadcast", "presence", or "postgres_changes".

    • filter: { event: string }

      Custom object specific to the Realtime feature detailing which payloads to receive.

      • event: string
    • callback: ((payload: { event: string; type: "broadcast" }) => void)

      Function to be invoked when event handler is triggered.

        • (payload: { event: string; type: "broadcast" }): void
        • Parameters

          • payload: { event: string; type: "broadcast" }
            • [key: string]: any
            • event: string
            • type: "broadcast"

          Returns void

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    • type: "broadcast"
    • filter: { event: string }
      • event: string
    • callback: ((payload: { event: string; payload: T; type: "broadcast" }) => void)
        • (payload: { event: string; payload: T; type: "broadcast" }): void
        • Parameters

          • payload: { event: string; payload: T; type: "broadcast" }
            • event: string
            • payload: T
            • type: "broadcast"

          Returns void

    Returns RealtimeChannel

  • Type Parameters

    • T extends {}

    Parameters

    • type: "system"
    • filter: {}
      • callback: ((payload: any) => void)
          • (payload: any): void
          • Parameters

            • payload: any

            Returns void

      Returns RealtimeChannel

    • Type Parameters

      • T extends {} = {}

      Returns RealtimePresenceState<T>

    • send(args: { event: string; payload?: any; type: "presence" | "postgres_changes" | "broadcast" }, opts?: {}): Promise<RealtimeChannelSendResponse>
    • Sends a message into the channel.

      Parameters

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

        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: {}

        Options to be used during the send process

        • [key: string]: any

      Returns Promise<RealtimeChannelSendResponse>

    • subscribe(callback?: ((status: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR", err?: Error) => void), timeout?: number): RealtimeChannel
    • Subscribe registers your client with the server

      Parameters

      • Optional callback: ((status: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR", err?: Error) => void)
          • (status: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR", err?: Error): void
          • Parameters

            • status: "SUBSCRIBED" | "TIMED_OUT" | "CLOSED" | "CHANNEL_ERROR"
            • Optional err: Error

            Returns void

      • Optional timeout: number

      Returns RealtimeChannel

    • Parameters

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

      Returns Promise<RealtimeChannelSendResponse>

    • unsubscribe(timeout?: number): Promise<"error" | "ok" | "timed out">
    • 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

      Returns Promise<RealtimeChannelSendResponse>

    • updateJoinPayload(payload: {}): void
    • Parameters

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

      Returns void

    Generated using TypeDoc