electron Main and renderer process. Remote module RMI


The remote module allows simple RMI (remote method invocation) of main process objects from renderer process. First create the main process in index.js

const {app, BrowserWindow} = require('electron')
let win = null

app.on('ready', () => {
  win = new BrowserWindow()
  win.on('closed', () => {
    win = null

and then remote process index.html

<!DOCTYPE html>
      const {BrowserWindow, app} = require('electron').remote
    <button onclick= "let win = new BrowserWindow(); win.loadURL(`file://${__dirname}/index.html`)">new window</button>
    <button onclick= "app.quit()">quit</button>