concept Mac OS in category electron
appears as: Mac OS, Mac OS

This is an excerpt from Manning's book Cross-Platform Desktop Applications: Using Node, Electron, and NW.js.
Listing 1.2. main.js file for the Hello World Electron app
'use strict'; const electron = require('electron'); #1 const app = electron.app; #2 const BrowserWindow = electron.BrowserWindow; #3 let mainWindow = null; #4 app.on('window-all-closed', () => { if (process.platform !== 'darwin') app.quit(); #5 }); app.on('ready', () => { #6 mainWindow = new BrowserWindow(); mainWindow.loadURL(`file://${__dirname}/index.html`); #7 mainWindow.on('closed', () => { mainWindow = null; }); #8 }); #1 - Loads Electron module from npm #2 - Creates reference to Electron’s application object #3 - Creates reference to Electron’s Browser-Window class #4 - mainWindow variable stores reference to app’s window #5 - Add event listener that quits the app when all windows are closed (except in Mac OS) #6 - Creates new app window and assigns it to main window variable to prevent it being closed by Node.js garbage collection #7 - Loads index.html file in app window #8 - When app window is closed, unassigns app window from main window variable
In this chapter, we’ll explore those options and show how to package your app as executable binaries for Mac OS, Microsoft Windows, and Linux (Ubuntu), including creating Windows installers for your Electron apps.