-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpreload.js
More file actions
22 lines (21 loc) · 901 Bytes
/
preload.js
File metadata and controls
22 lines (21 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electron', {
ipcRenderer: {
send: (channel, data) => ipcRenderer.send(channel, data),
on: (channel, func) => ipcRenderer.on(channel, (event, ...args) => func(...args))
},
//load in the information
loadJournal: async () => {
return await ipcRenderer.invoke("load-journal");
},
saveJournalEntry: async (journalEntries) => {
try {
// Use ipcRenderer.invoke to handle asynchronous calls
const response = await ipcRenderer.invoke('save-journal-entry', journalEntries);
return response; // You can return the response if needed
} catch (error) {
console.error('Failed to save journal entry:', error);
throw error; // Re-throw error to be handled in the calling function
}
}
});