As I embark on the journey of creating my first electron app, I kindly ask for your understanding :)
Upon clicking a button in the main Window, a new window should open displaying a JSON string. This action is captured by ipcMain:
ipcMain.on("JSON:ShowPage", function(e, item) {
createJSONWindow(item);
})
Below is the function responsible for generating the new window:
function createJSONWindow(item) {
let jsonWin = new BrowserWindow({
width: 600,
height: 800,
center: true,
resizable: true,
webPreferences:{
nodeIntegration: true,
show: false
}
});
jsonWin.loadFile("jsonView.html");
ipcMain.on('JSON_PAGE:Ready', function(event, arg) {
jsonWin.webContents.send('JSON:Display', item);
})
jsonWin.once('ready-to-show',()=>{
jsonWin.show()
});
jsonWin.on('closed',()=>{
jsonWin = null;
});
}
Now here lies my question - when multiple JSONWindow
s are opened, each one receives the JSON:Display
Message and updates its content. Shouldn't they operate independently? After all, jsonWin
is always a new BrowserWindow
, right?
I appreciate any advice you can offer.