generated from maximegris/angular-electron
-
Notifications
You must be signed in to change notification settings - Fork 16
/
preload.ts
30 lines (26 loc) · 994 Bytes
/
preload.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import {contextBridge, ipcRenderer} from 'electron';
console.log('preload.js loaded');
export const electronAPIKey = 'electron';
export const electronAPI = {
electronIpcSend: (channel: string, ...arg: any): void => {
ipcRenderer.send(channel, arg);
},
electronIpcSendSync: (channel: string, ...arg: any) => {
return ipcRenderer.sendSync(channel, arg);
},
electronIpcOn: (channel: string, listener: (event: any, ...arg: any) => void): void => {
ipcRenderer.on(channel, listener);
},
electronIpcOnce: (channel: string, listener: (event: any, ...arg: any) => void): void => {
ipcRenderer.once(channel, listener);
},
electronIpcRemoveListener: (channel: string, listener: (event: any, ...arg: any) => void): void => {
ipcRenderer.removeListener(channel, listener);
},
electronIpcRemoveAllListeners: (channel: string): void => {
ipcRenderer.removeAllListeners(channel);
}
};
contextBridge.exposeInMainWorld(
electronAPIKey, electronAPI
);