Skip to content

ElectronIpcMain.handle method

ElectronIpcMain › handle

Unofficial

Adds a handler for an invokeable IPC. This handler is called whenever a renderer calls ipcRenderer.invoke(channel, ...args).

If listener returns a Promise, the eventual result of the promise is returned as a reply to the remote caller. Otherwise, the return value of the listener is used as the value of the reply.

The event passed as the first argument to the handler is the same as that passed to a regular event listener. It includes information about which WebContents is the source of the invoke request.

Signature:

handle(channel: string, listener: (event: ElectronIpcMainInvokeEvent, ...args: unknown[]) => unknown): void

Parameters:

Parameter Type Description
channel string The IPC channel name.
listener (event: ElectronIpcMainInvokeEvent, ...args: unknown[]) => unknown Callback invoked to handle the message.

Returns: void