Electron and angularJS app architecture - SPA clone in two windows

Multi tool use


Electron and angularJS app architecture - SPA clone in two windows
In mainWindow of my application I have angularJS SPA. Everything is fine untill I create new window. In every window I need to loadURL which is path to HTML document like in mainWindow:
mainWindow = new BrowserWindow({
width: 790,
height: 580
});
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'index.html'), // load - index.html angularjs dashboard
slashes: true
}));
Problem is that since I have SPA in my mainWindow after I open new window I should load entire SPA to new window as well as in mainWindow and just redirect to correct (hidden) url so I would have some other content in this new one. I would need to load this entire SPA in order to have access to my SPA services, factories and directives which I need to use in new window.
let createQuestionWindow = () => {
questionWindow = new BrowserWindow({
width: 380,
height: 300,
alwaysOnTop: true
});
transparentWindow.loadURL(`file://${__dirname}/index.html`);
// in above line im actually loading same SPA as in mainWindow
questionWindow.isFocused();
questionWindow.setFocusable(true);
mainWindow.restore();
// here I should also redirect or set url somehow but...
};
createQuestionWindow();
I'm not even trying to set correct url in clone SPA in new window because it'll probably cause huge performance issues because in the end I would have open 2 or even 3 sometimes windows which would be exact same clones of SPA.
That's not very good solution I heard about "child window" but still it doesn't provide me ability to access parent SPA ( I think ).
How to refactor my application so I'll be able to access SPA from new windows but I'll do not need to load entire thing again and again?
If that's not possible to accomplish in other, better way then how to set url of SPA in new window from electron (node) side of app but in the way that angularJS router will catch it?
This question has not received enough attention.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.