Skip to content

ElectronMessagePortMain

Unofficial

The main-process end of a MessagePort channel.

Import:

import type { ElectronMessagePortMain } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface ElectronMessagePortMain

Methods

Method Returns Description
addListener(event, listener) this Registers a listener for the close event, emitted when the remote end becomes disconnected.
addListener(event, listener) this Registers a listener for the message event, emitted when the port receives a message.
close() void Disconnects the port, so it is no longer active.
on('close', listener) this Registers a listener for the close event, emitted when the remote end becomes disconnected.
on('message', listener) this Registers a listener for the message event, emitted when the port receives a message.
once(event, listener) this Registers a one-time listener for the close event.
once(event, listener) this Registers a one-time listener for the message event.
postMessage(message, transfer?) void Sends a message from the port, and optionally, transfers ownership of objects to other browsing contexts.
removeListener(event, listener) this Removes a previously registered close event listener.
removeListener(event, listener) this Removes a previously registered message event listener.
start() void Starts the sending of messages queued on the port. Messages will be queued until this method is called.

Links to this page: