Trigger new window in render, run events on main


#1

We currently need to login via a companies webpage (wordpress) so we must create a new window and run all those processes to get the user information. We have that working, but what we need is to trigger the window in the event process, but need to run the event emitters in the main process because it is highly suggest not to use remote for app and we need to write their information to a cached file.

Remote browser window says it is created in the main process but there is no way to run the emitters without an window ready or open. What would be the best way to go about this?


#2

A lot of people believe that they need to run stuff in the main process. In the vast majority of cases, you don’t and shouldn’t. See the discussion here:

(The above discussion uses the old terminology … atom-shell → electron and browser process → main process)


#3

But if I’m not in the main process then I don’t have access to app and app.getPath so I can save user information. Do I really use remote with app?


#4

You can subclass BrowserWindow and pass whatever information you need across to it when you construct it, including app.getPath. You also have all of the Node libraries at your disposal … so you could call process.cwd() or something.