fix: fiddle ipc code pattern 3 (#33262)
This commit is contained in:
parent
02fe245521
commit
b274011720
2 changed files with 3 additions and 3 deletions
|
@ -4,5 +4,5 @@ window.electronAPI.handleCounter((event, value) => {
|
||||||
const oldValue = Number(counter.innerText)
|
const oldValue = Number(counter.innerText)
|
||||||
const newValue = oldValue + value
|
const newValue = oldValue + value
|
||||||
counter.innerText = newValue
|
counter.innerText = newValue
|
||||||
event.reply('counter-value', newValue)
|
event.sender.send('counter-value', newValue)
|
||||||
})
|
})
|
||||||
|
|
|
@ -379,7 +379,7 @@ module that uses the `webContents.send` API to send an IPC message from the main
|
||||||
target renderer.
|
target renderer.
|
||||||
|
|
||||||
```javascript {11-26} title='main.js (Main Process)'
|
```javascript {11-26} title='main.js (Main Process)'
|
||||||
const {app, BrowserWindow, Menu} = require('electron')
|
const {app, BrowserWindow, Menu, ipcMain} = require('electron')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
function createWindow () {
|
function createWindow () {
|
||||||
|
@ -519,7 +519,7 @@ window.electronAPI.onUpdateCounter((event, value) => {
|
||||||
const oldValue = Number(counter.innerText)
|
const oldValue = Number(counter.innerText)
|
||||||
const newValue = oldValue + value
|
const newValue = oldValue + value
|
||||||
counter.innerText = newValue
|
counter.innerText = newValue
|
||||||
event.reply('counter-value', newValue)
|
event.sender.send('counter-value', newValue)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue