bruno/main/preload.js

14 lines
464 B
JavaScript
Raw Permalink Normal View History

2022-03-05 18:37:48 +01:00
const { ipcRenderer, contextBridge } = require('electron');
2022-03-22 13:48:20 +01:00
contextBridge.exposeInMainWorld('ipcRenderer', {
invoke: (channel, ...args) => ipcRenderer.invoke(channel, ...args),
on: (channel, handler) => {
// Deliberately strip event as it includes `sender`
const subscription = (event, ...args) => handler(...args);
ipcRenderer.on(channel, subscription);
return () => {
ipcRenderer.removeListener(channel, subscription);
};
2022-03-05 18:37:48 +01:00
}
2022-03-22 13:48:20 +01:00
});