IPC, Inter-Process Communication, I's said that some technologies or methods for transmitting information or signals between at least two processes or threads. The above description comes from WIKI, which means that the method of transmitting information between Main Process and BrowserWindow is IPC.
What is IPC?
Inter-Process Communication (IPC) refers to some technologies or methods for transmitting information or signals between at least two processes or threads.
The above description comes from WIKI, which means that the method of transmitting information between Main Process and BrowserWindow is IPC.
How does IPC work in Electron?
Electron provides IpcRenderer and IpcMain to facilitate engineers to perform IPC
- Screen side (BrowserWindow) uses IpcRenderer
- The main process side (Main Process) uses IpcMain
How to write the code in practice ?
Shown below are 3 modes of communication
- Someone else will pick you up
IpcMain.on monitors messages from IpcRenderer.send
Then use event.reply
to return
For example: after you bring the kitten home, you ask the mother to help take care of your kitten and let her help feed it.
- Wait for response You have been staring at the kitten because you are afraid that she will be hungry, but you have not done anything in the meantime.
- Notification response When you clean the house, The cub cat is hungry and will "meow"
The above three methods all start from the renderer process side. What should I do if I want to trigger the message from the main process?