A channel for broadcasting messages to other contexts listening on the same name.

Also available via worker_threads (see section 5); this is the web global form.

See also:

Constructor

new(name:String)

Variables

read onlyname:String

The channel name.

Methods

close():Void

Closes the channel.

postMessage(message:Any):Void

Posts a message that will be delivered to all other BroadcastChannel objects listening on the same name.

ref():BroadcastChannel

Increases the Node.js event-loop reference count for this channel. Returns this.

unref():BroadcastChannel

Decreases the Node.js event-loop reference count for this channel. Returns this.

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>):Void

Adds a new handler for the type event. Any given listener is added only once per type and per capture option value.

dispatchEvent(event:Event):Bool

Dispatches the event to the list of handlers for event.type.

Returns:

true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, otherwise false.

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes the listener from the list of handlers for event type.