electron/docs/fiddles/communication/two-processes/asynchronous-messages/renderer.js
Erick Zhao c2e77e4429 docs: add Asynchronous Messages Fiddle example (#20441)
* docs: add Asynchronous Messages Fiddle example

* Update docs/fiddles/communication/two-processes/asynchronous-messages/main.js

Co-Authored-By: John Kleinschmidt <jkleinsc@github.com>

* Update docs/fiddles/communication/two-processes/asynchronous-messages/index.html

Co-Authored-By: John Kleinschmidt <jkleinsc@github.com>
2019-10-10 09:49:07 -04:00

12 lines
378 B
JavaScript

const { ipcRenderer } = require('electron')
const asyncMsgBtn = document.getElementById('async-msg')
asyncMsgBtn.addEventListener('click', () => {
ipcRenderer.send('asynchronous-message', 'ping')
})
ipcRenderer.on('asynchronous-reply', (event, arg) => {
const message = `Asynchronous message reply: ${arg}`
document.getElementById('async-reply').innerHTML = message
})