ElectronIpcRenderer
Unofficial
Electron IPC renderer for communicating with the main process.
Import:
import type { ElectronIpcRenderer } from '@obsidian-typings/obsidian-catalyst-latest';Signature:
export interface ElectronIpcRenderer extends NodeJS.EventEmitterExtends: NodeJS.EventEmitter
Methods
| Method | Returns | Description | |
|---|---|---|---|
| invoke(channel, args?) | Promise<unknown> | Sends a message to the main process via channel and expects a result asynchronously.The main process should listen for channel with ipcMain.handle(). Arguments are serialized with the Structured Clone Algorithm, so prototype chains are not included and sending functions, promises, symbols, weak maps, or weak sets throws an exception. | |
| on(channel, listener) | this | Listens to channel; when a new message arrives listener is called with listener(event, args...). | |
| once(channel, listener) | this | Adds a one-time listener function for the event, invoked only the next time a message is sent to channel, after which it is removed. | |
| postMessage(channel, message, transfer?) | void | Sends a message to the main process, optionally transferring ownership of zero or more MessagePort objects. The transferred ports are available in the main process as MessagePortMain objects via the ports property of the emitted event. | |
| removeAllListeners(channel) | this | Removes all listeners of the specified channel. | |
| removeListener(channel, listener) | this | Removes the specified listener from the listener array for the specified channel. | |
| send(channel, args?) | void | Sends an asynchronous message to the main process via channel, along with arguments.The main process handles it by listening for channel with the ipcMain module. Arguments are serialized with the Structured Clone Algorithm, so prototype chains are not included and sending functions, promises, symbols, weak maps, or weak sets throws an exception. | |
| sendSync(channel, args?) | unknown | Sends a message to the main process via channel and expects a result synchronously.The main process handles it by listening for channel with the ipcMain module and replies by setting event.returnValue. Sending a synchronous message blocks the whole renderer process until the reply is received, so use this only as a last resort. | |
| sendTo(webContentsId, channel, args?) | void | Sends a message to a window with webContentsId via channel. | |
| sendToHost(channel, args?) | void | Like send, but the event is sent to the <webview> element in the host page instead of the main process. |
Links to this page: