typedelectron/assets/preload.js

10 lines
345 B
JavaScript
Raw Normal View History

2023-12-06 02:05:05 +00:00
const { contextBridge, ipcRenderer } = require('electron');
2023-12-06 01:16:36 +00:00
contextBridge.exposeInMainWorld('electronApi', {
sendMessage: async (channelNameArg, payloadArg) => {
ipcRenderer.send(channelNameArg, payloadArg);
},
receiveMessage: (channelNameArg, func) => {
ipcRenderer.on(channelNameArg, (event, ...args) => func(...args));
2023-12-06 02:05:05 +00:00
},
2023-12-06 01:16:36 +00:00
});