electron/docs/fiddles/ipc/pattern-3/preload.js
Milan Burda b163187235
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>
2023-11-01 13:46:25 -04:00

6 lines
292 B
JavaScript

const { contextBridge, ipcRenderer } = require('electron/renderer')
contextBridge.exposeInMainWorld('electronAPI', {
onUpdateCounter: (callback) => ipcRenderer.on('update-counter', (_event, value) => callback(value)),
counterValue: (value) => ipcRenderer.send('counter-value', value)
})