BroadcastChannel

The BroadcastChannel interface represents a named channel that any browsing context of a given origin can subscribe to.

MDN Reference

Constructors

Link copied to clipboard
constructor(name: String)

Properties

Link copied to clipboard

The name read-only property of the BroadcastChannel interface returns a string, which uniquely identifies the given channel with its name.

Functions

Link copied to clipboard
fun <E : Event> EventTargetLike.addEventListener(type: EventType<E>, handler: (E) -> Unit, options: AddEventListenerOptions? = undefined)

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

Link copied to clipboard
open override fun close()

The close() method of the BroadcastChannel interface terminates the connection to the underlying channel, allowing the object to be garbage collected.

Link copied to clipboard
open fun dispatchEvent(event: Event): Boolean

The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order.

Link copied to clipboard
fun postMessage(message: String)

fun postMessage(message: JsAny?)

The postMessage() method of the BroadcastChannel interface sends a message, which can be of any kind of Object, to each listener in any browsing context with the same origin.

Link copied to clipboard
fun <E : Event> EventTargetLike.removeEventListener(type: EventType<E>, handler: (E) -> Unit, options: EventListenerOptions? = undefined)

The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target.

Link copied to clipboard
fun <T : Event> when(type: EventType<T>, options: ObservableEventListenerOptions? = definedExternally): Observable<T>