docs: add Synchronous Messages Fiddle example (#20451)

* docs: add Synchronous Messages Fiddle example

* Code review changes

* Add OS support info
This commit is contained in:
Amarnath Karthi 2019-11-01 23:32:42 +05:30 committed by John Kleinschmidt
parent dcf6f046d9
commit 0fe718b1d9
3 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1,29 @@
const { app, BrowserWindow, ipcMain } = require('electron')
let mainWindow = null
function createWindow () {
const windowOptions = {
width: 600,
height: 400,
title: 'Synchronous Messages',
webPreferences: {
nodeIntegration: true
}
}
mainWindow = new BrowserWindow(windowOptions)
mainWindow.loadFile('index.html')
mainWindow.on('closed', () => {
mainWindow = null
})
}
app.on('ready', () => {
createWindow()
})
ipcMain.on('synchronous-message', (event, arg) => {
event.returnValue = 'pong'
})