I took out the irrelevant parts:
main.js
let window = null;
app.on('ready', () => {
window = new BrowserWindow({
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
enableRemoteModule: false,
preload: path.join(__dirname, "preload.js")
}
});
window.loadFile('index.html')
.then(() => {})
.catch(err => console.log(err));
});
I have a timeout in main.js that calls
window.webContents.send('store-data', "MESSAGE");
preload.js
const {contextBridge,ipcRenderer} = require('electron');
contextBridge.exposeInMainWorld('electron', {
storeData: (channel, data) => {
ipcRenderer.on(channel, (event, data) => {
return data;
});
}
});
index.html
window.electron.storeData('store-data', (data) =>{
console.log(data);
});
This is working in that I get an object on the index.html side, but no data.