docs: avoid leaking the IpcRendererEvent
in contextBridge
examples (#40321)
* docs: avoid leaking the `IpcRendererEvent` in `contextBridge` examples * Update docs/fiddles/ipc/pattern-3/preload.js Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * Update docs/tutorial/ipc.md Co-authored-by: David Sanders <dsanders11@ucsbalum.com> * Update docs/tutorial/ipc.md Co-authored-by: David Sanders <dsanders11@ucsbalum.com> --------- Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
This commit is contained in:
parent
425efb5e47
commit
b163187235
3 changed files with 23 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron/renderer')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
handleCounter: (callback) => ipcRenderer.on('update-counter', () => callback())
|
||||
onUpdateCounter: (callback) => ipcRenderer.on('update-counter', (_event, value) => callback(value)),
|
||||
counterValue: (value) => ipcRenderer.send('counter-value', value)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue