Skip to content

Instantly share code, notes, and snippets.

@MarshallOfSound
Created March 27, 2019 17:19
Show Gist options
  • Save MarshallOfSound/c89aa0037c3da114d44aa3a2d1a0fc24 to your computer and use it in GitHub Desktop.
Save MarshallOfSound/c89aa0037c3da114d44aa3a2d1a0fc24 to your computer and use it in GitHub Desktop.
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>
const {app, BrowserWindow, ipcMain} = require('electron')
let mainWindow
ipcMain.on('ping', (event, ...args) => console.log('pong', ...args))
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
preload: require('path').resolve(__dirname, 'renderer.js')
}
})
// and load the index.html of the app.
mainWindow.loadURL('https://google.com')
setTimeout(() => {
mainWindow.loadURL('https://google.com')
}, 2000);
setTimeout(() => {
mainWindow.loadURL('https://google.com')
}, 4000);
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
app.quit()
})
require('electron').ipcRenderer.send('ping', 'before loop', process.pid);
const now = Date.now();
while (Date.now() - now < 7000) {
}
require('electron').ipcRenderer.send('ping', 'after loop', process.pid);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment