@statesync/electron / ElectronIpcRendererLike
Interface: ElectronIpcRendererLike
Defined in: types.ts:30
Structural type matching the subset of Electron's ipcRenderer API required by createElectronBridge.
Consumers can pass the real ipcRenderer from 'electron' or any compatible mock/stub for testing.
Process context: preload script (Node.js context with contextIsolation).
Example
// In preload.ts
import { ipcRenderer } from 'electron';
import { createElectronBridge } from '@statesync/electron';
const bridge = createElectronBridge(ipcRenderer);Methods
invoke()
invoke(channel, ...args): Promise<unknown>;Defined in: types.ts:58
Sends an IPC message to the main process and asynchronously returns the response.
Parameters
| Parameter | Type | Description |
|---|---|---|
channel | string | The IPC channel name to invoke. |
...args | unknown[] | Optional arguments forwarded to the ipcMain.handle() handler. |
Returns
Promise<unknown>
A promise resolving to the value returned by the main-process handler.
on()
on(channel, listener): unknown;Defined in: types.ts:40
Registers a listener for messages on the given IPC channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
channel | string | The IPC channel name to listen on. |
listener | (event, ...args) => void | Callback invoked when a message arrives. The first argument is the Electron IpcRendererEvent (typed as unknown for structural compatibility), followed by any payload arguments sent from the main process. |
Returns
unknown
Implementation-defined (the return value is not used by state-sync).
removeListener()
removeListener(channel, listener): unknown;Defined in: types.ts:49
Removes a previously registered listener for the given IPC channel.
Parameters
| Parameter | Type | Description |
|---|---|---|
channel | string | The IPC channel name to stop listening on. |
listener | (event, ...args) => void | The exact function reference originally passed to on. |
Returns
unknown
Implementation-defined (the return value is not used by state-sync).
