Neutralino.window.create('/') and Events
Expected behavior I click a button and create a 2nd instance of the app with window.create('/');. When I broadcast an event both instances receive it.
Actual behavior When I broadcast an event, no matter if I use events.broadcast, events.dispatch or app.broadcast, the event only registers in the current window.
I'm new to this so maybe I don't understand how this works but I thought this is how it's supposed to work? If I misunderstood, please correct me and let me know if there is a better way of sending an event to all app instances. I'm using PIXI.js in the project but I don't think it's relevant in this scenario. The way I did it before was with .storage but that's really annoying.
Here's my code:
We make an event listener
async function eventing(){
await Neutralino.events.on('balrog', shakira);
};
eventing();Then we make a function to call the event (how we call this function is irrelevant I think):
async function goevent(){
await Neutralino.events.broadcast('balrog');
};And here's the stupid function that gets called by the event:
function shakira(){
console.log('shakira');
let movingoX = Math.random() * (window.screen.availWidth / 2 - 1) + 1;
let movingoY = Math.random() * (window.screen.availHeight / 2 - 1) + 1;
window.Neutralino.window.move(movingoX, movingoY);
let sizeoY = Math.random() * (window.screen.availHeight / 1.5 - 288) + 288;
let sizeoX = (sizeoY / 3) * 4;
window.Neutralino.window.setSize({
width: sizeoX,
height: sizeoY
});
};And the code I use for making a 2nd window, if it matters:
window.Neutralino.window.create('/');
Basically, I'd expect both windows to move and resize on click (when the event gets broadcasted) but only the window I clicked the button in does.
Running on: NeutralinoJs Version: 3.3.0 NeutralinoJs CLI version: 4.4.0 Windows 10
Source: neutralinojs/neutralinojs