Suppose we have the following 2 BrowserWindow instances created in main process:
let fooA = new BrowserWindow({width:800,height:800});
fooA.loadUrl(url.format({
pathname: path.join(__dirname, './a.html'),
protocol: 'file:',
slashes: true
}));
let fooB = new BrowserWindow({parent:fooA});
fooB.loadUrl(url.format({
pathname: path.join(__dirname, './b.html'),
protocol: 'file:',
slashes: true
}));
As you can see fooB
is child of fooA
Now each browsers window html file is associated with a renderer
process:
fooA
is associated with rendererA.js
and fooB
is associated with rendererB.js
Now let's say I want to send a message from rendererA
to rendererB
Do I have to first send a message to main process and the after the main receives it to inform rendererB
by using fooB.webContents.send('message-to-b',"rendererA says hello")
or is there an easier way since fooA
is the parent of fooB
.