One end of a two-way communication channel created by MessageChannel.

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

See also:

Variables

Methods

close():Void

Disconnects the port and stops receiving messages.

postMessage(message:Any, ?transfer:Array<MessagePortTransferable>):Void

Posts a message through the channel. transfer is a list of transferable objects to transfer ownership of (ArrayBuffer, MessagePort, AbortSignal, or web streams).

start():Void

Starts dispatching messages received on this port. (Implicit when onmessage is set.)

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.