The MessagePort interface of the Channel Messaging API 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.
Properties Jump to heading
Jump to headingonmessage: ((this: MessagePort,ev: MessageEvent,) => any) | nullJump to headingonmessageerror: ((this: MessagePort,ev: MessageEvent,) => any) | nullMethods Jump to heading
Jump to headingclose(): voidDisconnects the port, so that it is no longer active.
Jump to headingpostMessage(message: any,transfer: Transferable[],): voidPosts 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.
Throws a "DataCloneError" DOMException if transfer contains duplicate objects or port, or if message could not be cloned.
Jump to headingpostMessage(message: any,options?: StructuredSerializeOptions,): voidJump to headingstart(): voidBegins dispatching messages received on the port. This is implicitly called
when assigning a value to this.onmessage.
Jump to headingaddEventListener<K extends keyof MessagePortEventMap>(type: K,listener: (this: MessagePort,ev: MessagePortEventMap[K],) => any,options?: boolean | AddEventListenerOptions,): voidJump to headingaddEventListener(type: string,listener: EventListenerOrEventListenerObject,options?: boolean | AddEventListenerOptions,): voidJump to headingremoveEventListener<K extends keyof MessagePortEventMap>(type: K,listener: (this: MessagePort,ev: MessagePortEventMap[K],) => any,options?: boolean | EventListenerOptions,): void