diff --git a/api-reports/2_12.txt b/api-reports/2_12.txt index b9f9637ca..7d344997f 100644 --- a/api-reports/2_12.txt +++ b/api-reports/2_12.txt @@ -612,6 +612,16 @@ Body[JT] def bodyUsed: Boolean Body[JT] def formData(): js.Promise[FormData] Body[JT] def json(): js.Promise[js.Any] Body[JT] def text(): js.Promise[String] +BroadcastChannel[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +BroadcastChannel[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +BroadcastChannel[JC] def close(): Unit +BroadcastChannel[JC] def dispatchEvent(evt: Event): Boolean +BroadcastChannel[JC] def name: String +BroadcastChannel[JC] var onmessage: js.Function1[MessageEvent, _] +BroadcastChannel[JC] var onmessageerror: js.Function1[MessageEvent, _] +BroadcastChannel[JC] def postMessage(message: Any): Unit +BroadcastChannel[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +BroadcastChannel[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit CDATASection[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit CDATASection[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit CDATASection[JC] def appendChild(newChild: Node): Node diff --git a/api-reports/2_13.txt b/api-reports/2_13.txt index b9f9637ca..7d344997f 100644 --- a/api-reports/2_13.txt +++ b/api-reports/2_13.txt @@ -612,6 +612,16 @@ Body[JT] def bodyUsed: Boolean Body[JT] def formData(): js.Promise[FormData] Body[JT] def json(): js.Promise[js.Any] Body[JT] def text(): js.Promise[String] +BroadcastChannel[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +BroadcastChannel[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit +BroadcastChannel[JC] def close(): Unit +BroadcastChannel[JC] def dispatchEvent(evt: Event): Boolean +BroadcastChannel[JC] def name: String +BroadcastChannel[JC] var onmessage: js.Function1[MessageEvent, _] +BroadcastChannel[JC] var onmessageerror: js.Function1[MessageEvent, _] +BroadcastChannel[JC] def postMessage(message: Any): Unit +BroadcastChannel[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit +BroadcastChannel[JC] def removeEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit CDATASection[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], options: EventListenerOptions): Unit CDATASection[JC] def addEventListener[T <: Event](`type`: String, listener: js.Function1[T, _], useCapture: Boolean?): Unit CDATASection[JC] def appendChild(newChild: Node): Node diff --git a/dom/src/main/scala/org/scalajs/dom/BroadcastChannel.scala b/dom/src/main/scala/org/scalajs/dom/BroadcastChannel.scala new file mode 100644 index 000000000..9ee800c99 --- /dev/null +++ b/dom/src/main/scala/org/scalajs/dom/BroadcastChannel.scala @@ -0,0 +1,33 @@ +package org.scalajs.dom + +import scala.scalajs.js +import scala.scalajs.js.annotation.JSGlobal + +/** A named channel that any browsing context of a given origin can subscribe to. It allows communication between + * different documents (in different windows, tabs, frames or iframes) of the same origin. Messages are broadcasted via + * a message event fired at all BroadcastChannel objects listening to the channel, except the object that sent the + * message. + */ +@js.native +@JSGlobal +class BroadcastChannel(channelName: String) extends EventTarget { + + /** Uniquely identifies the given channel with its name */ + def name: String = js.native + + /** terminates the connection to the underlying channel, allowing the object to be garbage collected */ + def close(): Unit = js.native + + /** Sends a message, which can be of any kind of Object, to each listener in any browsing context with the same origin + */ + def postMessage(message: Any): Unit = js.native + + /** The message event is fired on a BroadcastChannel object when a message arrives on that channel */ + var onmessage: js.Function1[MessageEvent, _] = js.native + + /** The messageerror event is fired on a BroadcastChannel object when a message that can't be deserialized arrives on + * the channel + */ + var onmessageerror: js.Function1[MessageEvent, _] = js.native + +}