organizing things and cracking problem with the polyfills i think?
This commit is contained in:
@@ -1,26 +1,42 @@
|
||||
import { contextBridge, ipcRenderer } from "electron";
|
||||
|
||||
import Channels from "./constants";
|
||||
import { STORE_ITEMS } from "./store";
|
||||
import { STORE_ITEMS } from "./constants";
|
||||
|
||||
const electronAPI = {
|
||||
auth: {
|
||||
initiateLogin() {
|
||||
ipcRenderer.send(Channels.ACTIVATE_LOG_IN);
|
||||
},
|
||||
receiveTokens(channel: Channels, func: any) {
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
},
|
||||
},
|
||||
store: {
|
||||
get(val: STORE_ITEMS) {
|
||||
return ipcRenderer.sendSync("electron-store-get", val);
|
||||
return ipcRenderer.invoke("electron-store-get", val);
|
||||
},
|
||||
set(property: STORE_ITEMS, val: any) {
|
||||
ipcRenderer.send("electron-store-set", property, val);
|
||||
},
|
||||
// Other method you want to add like has(), reset(), etc.
|
||||
},
|
||||
|
||||
on(channel: Channels, func: any) {
|
||||
const validChannels = ["ipc-example"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
// // Deliberately strip event as it includes `sender`
|
||||
// ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
// }
|
||||
|
||||
ipcRenderer.on(channel, (event, ...args) => func(...args));
|
||||
},
|
||||
once(channel: Channels, func: any) {
|
||||
// const validChannels = ["ipc-example"];
|
||||
// if (validChannels.includes(channel)) {
|
||||
// // Deliberately strip event as it includes `sender`
|
||||
// ipcRenderer.once(channel, (event, ...args) => func(...args));
|
||||
// }
|
||||
|
||||
ipcRenderer.once(channel, (event, ...args) => func(...args));
|
||||
},
|
||||
};
|
||||
|
||||
contextBridge.exposeInMainWorld("electronAPI", electronAPI);
|
||||
|
||||
Reference in New Issue
Block a user