MessagePort

This Channel Messaging API interface 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.

MDN Reference

Functions

Link copied to clipboard
fun close()

Disconnects the port, so that it is no longer active.

Link copied to clipboard
Link copied to clipboard
fun postMessage(message: Any?, transfer: ReadonlyArray<Transferable>)

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.

fun postMessage(message: Any?, options: StructuredSerializeOptions = definedExternally)
Link copied to clipboard
fun start()

Begins dispatching messages received on the port.