Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts>BroadcastChannel

A modern runtime for JavaScript and TypeScript.
Go to Latest
interface BroadcastChannel
implements EventTarget
import { type BroadcastChannel } from "https://deno.land/x/deno@v1.39.0/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts";

Properties

readonly
name: string

Returns the channel name (as passed to the constructor).

onmessage: ((this: BroadcastChannel, ev: MessageEvent) => any) | null
onmessageerror: ((this: BroadcastChannel, ev: MessageEvent) => any) | null

Methods

close(): void

Closes the BroadcastChannel object, opening it up to garbage collection.

postMessage(message: any): void

Sends the given message to other BroadcastChannel objects set up for this channel. Messages can be structured objects, e.g. nested objects and arrays.

addEventListener<K extends keyof BroadcastChannelEventMap>(
type: K,
listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void
addEventListener(
type: string,
options?: boolean | AddEventListenerOptions,
): void
removeEventListener<K extends keyof BroadcastChannelEventMap>(
type: K,
listener: (this: BroadcastChannel, ev: BroadcastChannelEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void
removeEventListener(
type: string,
options?: boolean | EventListenerOptions,
): void
variable BroadcastChannel
import { BroadcastChannel } from "https://deno.land/x/deno@v1.39.0/ext/broadcast_channel/lib.deno_broadcast_channel.d.ts";

type

{ readonly prototype: BroadcastChannel; new (name: string): BroadcastChannel; }