Header menu logo fable-electron-docs-api

ipcMain Type

⚠ Process Availability: Main ✔ | Renderer ❌ | Utility ❌ | Exported ✔### ipcMain> Communicate asynchronously from the main process to renderer processes.Process: MainThe ipcMain module is an Event Emitter. When used in the main process, it handles asynchronous and synchronous messages sent from a renderer process (web page). Messages sent from a renderer will be emitted to this module.For usage examples, check out the IPC tutorial.### Sending messagesIt is also possible to send messages from the main process to the renderer process, see webContents.send for more information.* When sending a message, the event name is the channel.* To reply to a synchronous message, you need to set event.returnValue.* To send an asynchronous message back to the sender, you can use event.reply(...). This helper method will automatically handle messages coming from frames that aren't the main frame (e.g. iframes) whereas event.sender.send(...) will always send to the main frame.

Static members

Static member Description

ipcMain.addListener (channel, listener)

Full Usage: ipcMain.addListener (channel, listener)

Parameters:
Modifiers: inline

Alias for ipcMain.on.

channel : string
listener : IpcMainEvent * obj[] -> unit

ipcMain.handle (channel, listener)

Full Usage: ipcMain.handle (channel, listener)

Parameters:
Modifiers: inline

Adds a handler for an invokeable IPC. This handler will be called whenever a renderer calls ipcRenderer.invoke(channel, ...args).If listener returns a Promise, the eventual result of the promise will be returned as a reply to the remote caller. Otherwise, the return value of the listener will be used as the value of the reply.The event that is 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.Errors thrown through handle in the main process are not transparent as they are serialized and only the message property from the original error is provided to the renderer process. Please refer to #24427 for details.

channel : string
listener : IpcMainInvokeEvent * obj[] -> U2<Promise<obj>, obj>

ipcMain.handleOnce (channel, listener)

Full Usage: ipcMain.handleOnce (channel, listener)

Parameters:
Modifiers: inline

Handles a single invokeable IPC message, then removes the listener. See ipcMain.handle(channel, listener).

channel : string
listener : IpcMainInvokeEvent * obj[] -> U2<Promise<obj>, obj>

ipcMain.off (channel, listener)

Full Usage: ipcMain.off (channel, listener)

Parameters:
Modifiers: inline

Removes the specified listener from the listener array for the specified channel.

channel : string
listener : IpcMainEvent * obj[] -> unit

ipcMain.on (channel, listener)

Full Usage: ipcMain.on (channel, listener)

Parameters:
Modifiers: inline

Listens to channel, when a new message arrives listener would be called with listener(event, args...).

channel : string
listener : IpcMainEvent * obj[] -> unit

ipcMain.once (channel, listener)

Full Usage: ipcMain.once (channel, listener)

Parameters:
Modifiers: inline

Adds a one time listener function for the event. This listener is invoked only the next time a message is sent to channel, after which it is removed.

channel : string
listener : IpcMainEvent * obj[] -> unit

ipcMain.removeAllListeners ?channel

Full Usage: ipcMain.removeAllListeners ?channel

Parameters:
    ?channel : string

Modifiers: inline

Removes all listeners from the specified channel. Removes all listeners from all channels if no channel is specified.

?channel : string

ipcMain.removeHandler channel

Full Usage: ipcMain.removeHandler channel

Parameters:
    channel : string

Modifiers: inline

Removes any handler for channel, if present.

channel : string

ipcMain.removeListener (channel, listener)

Full Usage: ipcMain.removeListener (channel, listener)

Parameters:
    channel : string
    listener : obj[] -> unit

Modifiers: inline

Alias for ipcMain.off.

channel : string
listener : obj[] -> unit

Type something to start searching.