electron/docs/fiddles/communication/two-processes/asynchronous-messages/renderer.js

13 lines
378 B
JavaScript
Raw Normal View History

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
})