Electron IPC de principal para renderizador
// 4. The main process sends messages to the rendering process proactively
// The main process sends a message to the rendering process.
// ipcMain.js
const {BrowserWindow} = require("electron");
BrowserWindow.getFocusedWindow().webContents.send(
"rendererMsg",
{msg:"Messages proactively sent by the main process to the rendering process"}
)
// The rendering process listens for messages sent by the host process.
// ipcRenderer.js
const {ipcRenderer} =require("electron");
window.onload = () => {
// Listen for messages sent by the host process on its own initiative
ipcRenderer.on("rendererMsg",(e,data)=>{
console.log(data);
// {'msg':'Messages proactively sent by the host process to the rendering process'}
});
}
SirSundays