Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 652 Bytes

best-practices.md

File metadata and controls

27 lines (19 loc) · 652 Bytes

Electron / Best Practices

Don't use ipcRenderer.sendSync

As explained in the docs:

Sending a synchronous message will block the whole renderer process, unless you know what you are doing you should never use it.

For example, the following code completely freezes the app:

// renderer
ipcRenderer.sendSync("event-key");
// main
ipcMain.on("event-key", event => {});

Subscribe main's event listeners as soon as possible

This way the messages won't get lost.

app.on("ready", () => {
    subscribeListeners();

    // ...
});