Tuesday 16 May 2017

Electron pass BrowserWindow to external main function (not IPC)

I understand and can implement both IPC and .remote() from main <--> renderers.
This question is about an external function still in the main thread and sharing the instantiated BowerserWindow.

For example, main.js:

... 
let mainWindow = null;
...
mainWindow = new BrowserWindow({
    show: false, 
    width: 1024, 
    height: 728
});
...

I'm trying to access mainWindow from foo.js and can't seem to get there.

Psuedocode:

export default () => {
    let win = mainWindow // from main.js;
    win.webContents.send('toast', 'woohoo'); // Arbitrary Render side listener
}



via Mark

No comments:

Post a Comment