Skip to main content

interface RemoteChannel.SimpleMessagePort

Interface used to perform low-level message communication between processes. Compatible with browser, Node, and Worker contexts.

Methods

addEventListener

Adds a message listener to the message port.

Definition

addEventListener(type: 'message', listener: (ev: {
      data: any;
    }) => any, options?: boolean | {
      once?: boolean;
    }): void;

Parameters

NameTypeDescription
type'message'only 'message' is supported.
listener(ev: {
      data: any;
    }) => any
a callback function receiving the message data
optionsboolean | {
      once?: boolean;
    }
(optional) callback options

postMessage

Sends a message to the message port.

Definition

postMessage(message: any): void;

Parameters

NameTypeDescription
messageanythe message to send

removeEventListener

Removes a message listener from the message port.

Definition

removeEventListener(type: 'message', listener: (ev: {
      data: any;
    }) => any): void;

Parameters

NameTypeDescription
type'message'only 'message' is supported.
listener(ev: {
      data: any;
    }) => any
a callback function receiving the message data