typedelectron/assets/preload.js

10 lines
341 B
JavaScript
Raw Normal View History

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