https://www.electronjs.org/docs/api/ipc-renderer https://www.electronjs.org/docs/api/ipc-main
I see an article that invoke / handle is asynchronous, but it's possible to use the old send / on. It is easy to return the return value. You do not need to specify webcontents when sending from Main to renderer. The benefits are understandable
https://medium.com/@nornagon/electrons-remote-module-considered-harmful-70d69500f31 I don't think the remote module written in this article is relevant to send / on
The ipcMain module is used to communicate asynchronously from the main process to renderer processes. When used in the main process, the module handles asynchronous and synchronous messages sent from a renderer process (web page). The messages sent from a renderer will be emitted to this module.
To send a message back to the renderer you would use: win. webContents. send('asynchronous-message', {'SAVED': 'File Saved'});
invoke
is new api to help ergonomics around existing send
/ on
pair when try to invoke some fn to return values to the sender. You can achieve same thing via send
if you prefer to use it, there's no functional differences.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With