Closed Ryeonnie closed 4 years ago
ipcRenderer.sendSync()
is syncronous and as written in documentation will block the process until response is received.
Note: Sending a synchronous message will block the whole renderer process, unless you know what you are doing you should never use it.
I see no benefit of using it instead of this package.
My mistake, let me explain..
win.webContents.send('main-process-message', false);
ipcRenderer.on("main-process-message", (event, arg) => {
state.isActivated = arg;
});
What I want to talk about is handle
and invoke
, which are new added features in electron v7.0.0: Release Notes
Related article: Electron’s ‘remote’ module considered harmful
If electron-better-ipc
is based old electron apis, it'd better to use original new apis for maximizing performance. And as you can see, the code is neat, clean and dead simple.
ipcMain.handle("windowOperator",async (event, ...args) => {})
await ipcRenderer.invoke("renderer-process-message", argument);
That is a good point, I just discovered this API. I tried using it instead of this module in my current project, seems like it works the same way.
I am considering whether it is better to switch to new API in electron v7 or not ?