I'm learning Electron and working with multiple windows and IPC. In my main script I have the following:
var storeWindow = new BrowserWindow({
width: 400,
height: 400,
show: false
});
ipc.on('show-store-edit', function(event, store) {
console.log(store);
storeWindow.loadURL('file://' + __dirname + '/app/store.html');
storeWindow.show();
});
And in my primary window's script, I have the following inside of a click event handler, pulling in a list of stores:
$.getJSON("http://localhost:8080/stores/" + item.id).done(function(store) {
ipc.send('show-store-edit', store);
});
On the console, I am printing the store data from my server. What I'm unclear on is how to get that data into the view for my storeWindow:store.html
. I'm not even sure I'm handling the sequence of events correctly but they would be:
- click Edit Store
- get store data from server
- open new window to display store data
or
- click Edit Store
- open new window to display store data
- get store data from server
In the latter, I'm not sure how I would get the ID required to fetch the store from the storeWindow's
script.