Messaging
Facilitate communication between different parts of an application, allowing data exchange and coordination.
interface BroadcastChannel
Represents a named channel that any BroadcastChannel with the same name (across workers or isolates in the same Deno process) can use to send and receive messages, allowing one-to-many communication between execution contexts.
Properties
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,
listener: EventListenerOrEventListenerObject,
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,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void variable BroadcastChannel
The constructor object for BroadcastChannel.
Construct a channel with new BroadcastChannel(name) to join the channel identified by name; messages posted on it are delivered to every other BroadcastChannel connected to the same name.
Properties
prototype: BroadcastChannel interface BroadcastChannelEventMap
Properties
interface MessageChannel
The MessageChannel interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
Properties
port1: MessagePort port2: MessagePort variable MessageChannel
The MessageChannel interface of the Channel Messaging API allows us to create a new message channel and send data through it via its two MessagePort properties.
Properties
prototype: MessageChannel interface MessagePort
The MessagePort interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
Properties
onmessage: ((
this: MessagePort,
ev: MessageEvent,
) => any) | null onmessageerror: ((
this: MessagePort,
ev: MessageEvent,
) => any) | null Methods
close(): void Disconnects the port, so that it is no longer active.
postMessage(
message: any,
transfer: Transferable[],
): void Posts a message through the channel. Objects listed in transfer are transferred, not just cloned, meaning that they are no longer usable on the sending side.
Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned.
postMessage(
message: any,
options?: StructuredSerializeOptions,
): void start(): void Begins dispatching messages received on the port. This is implicitly called when assigning a value to this.onmessage.
addEventListener<K extends keyof MessagePortEventMap>(
type: K,
listener: (
this: MessagePort,
ev: MessagePortEventMap[K],
) => any,
options?: boolean | AddEventListenerOptions,
): void addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void removeEventListener<K extends keyof MessagePortEventMap>(
type: K,
listener: (
this: MessagePort,
ev: MessagePortEventMap[K],
) => any,
options?: boolean | EventListenerOptions,
): void removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void variable MessagePort
The MessagePort interface of the Channel Messaging API represents one of the two ports of a MessageChannel, allowing messages to be sent from one port and listening out for them arriving at the other.
Properties
prototype: MessagePort interface MessagePortEventMap
Properties
© 2018–2025 the Deno authors
Licensed under the MIT License.
https://docs.deno.com/api/web/messaging