concept browser window in category electron

appears as: browser windows, browser window, browser window
Electron in Action

This is an excerpt from Manning's book Electron in Action.

NW.js applications start from an HTML page. Each browser window shares a common Node process. If more than one window is opened, they all share the same Node process. Electron keeps the Node and browser processes separate. In Electron, you start a main process from Node. This main process can open browser windows, each of which is its own process. Electron provides APIs for facilitating communication between the main process and the browser windows, which we call renderer processes throughout this book.

In index.html, we add the markup in listing 3.3 to create the browser window in figure 3.5.

Listing 6.23. Closing the watcher when the browser window closes: ./app/main.js
const createWindow = exports.createWindow = () => {
  let x, y;

  const currentWindow = BrowserWindow.getFocusedWindow();

  if (currentWindow) {
    const [ currentWindowX, currentWindowY ] = currentWindow.getPosition();
    x = currentWindowX + 10;
    y = currentWindowY + 10;
  }

  let newWindow = new BrowserWindow({ x, y, show: false });

  newWindow.loadFile('index.html');

  newWindow.once('ready-to-show', () => {
    newWindow.show();
  });

  newWindow.on('close', (event) => {
    if (newWindow.isDocumentEdited()) {
  // ...
    }
  });

  newWindow.on('closed', () => {
    windows.delete(newWindow);
    stopWatchingFile(newWindow);        #1
    newWindow = null;
  });

  windows.add(newWindow);
  return newWindow;
};
Figure 10.2. By default, menubar creates a browser window but does not load an HTML document into it.