Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what's the difference with invoke handle in Electron v7 #25

Closed
Ryeonnie opened this issue Oct 30, 2019 · 3 comments
Closed

what's the difference with invoke handle in Electron v7 #25

Ryeonnie opened this issue Oct 30, 2019 · 3 comments

Comments

@Ryeonnie
Copy link

I am considering whether it is better to switch to new API in electron v7 or not ?

@Laruxo
Copy link

Laruxo commented Nov 7, 2019

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.

@Ryeonnie Ryeonnie changed the title what's the difference with ipcRenderer.sendSync() in Electron v7 what's the difference with invoke handle in Electron v7 Nov 7, 2019
@Ryeonnie
Copy link
Author

Ryeonnie commented Nov 7, 2019

My mistake, let me explain..

main --> renderer

main process
win.webContents.send('main-process-message', false);
renderer process
ipcRenderer.on("main-process-message", (event, arg) => {
        state.isActivated = arg;
});

renderer --> main

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.

main process
ipcMain.handle("windowOperator",async (event, ...args) => {})
renderer process
await ipcRenderer.invoke("renderer-process-message", argument);

@Laruxo
Copy link

Laruxo commented Nov 7, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants