Aller au contenu

Electron IPC API

Ce contenu n’est pas encore disponible dans votre langue.

The invoke schema holds one entry per invoke channel: the guard that checks its argument, and its result type. The channel contracts define the one-way channels. Shared data types describe the payloads. The renderer calls main through window.electron.ipcRenderer.

The invoke schema and the channel contracts are the current channel list. This page does not repeat them.

A channel is called in one of three ways. invoke sends a request to main and returns a result. sendMessage sends a command without a result. on receives an event from main.

Expected failures use the shared Result type. Callers handle tagged errors by name. An unexpected throw at the IPC boundary becomes an UNEXPECTED_ERROR with an incident ID.

For an invoke channel, add one entry to the invoke schema and one entry to the route table. A missing route does not compile. For a one-way channel, define the payload in the channel contracts and register a listener in the IPC folder. Keep shared data shapes in the shared contracts. For an event to the renderer, use the typed send helpers and attach a listener with cleanup. Add a test at the boundary where behavior changes.