I'm new to desktop application development and am using Electron with node.js and javascript to build my app. Here is a short description of what I'm trying to achieve:
FirstWindow.html
has list of products with each list item associated with event listener double click. On double clicking any element.
SecondWindow.html
is supposed to be created which has the information of clicked product which is fetched from the database (postgesql). But on opening the app I get the following error:
Uncaught Exception: Attempting to call a function in a renderer window that has been closed or released
Here is my code snippet where I've tried to implement ipcMain and ipcRenderer modules:
main.js
const electron = require('electron');
ipcMain.on('item_catch_in_main', function(e, productname){
SecondWindow.webContents.send('item_action_to_be_done', productname);
});
FirstWindow.html
<script>
const { ipcRenderer } = require('electron');
ipcRenderer.send('item_catch_in_main', productname);
</script>
SecondWindow.html
<script>
const { ipcRenderer } = require('electron');
ipcRenderer.on('item_action_to_be_done', (event, item) => {
console.log(item);
});
</script>
Please let me know if anyone has worked around similar problem in Elecrton. Thanks in advance!