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

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

Links to this page: