For an electron-app I use a global variable to store some constantly changing values in my administration panel (mainly status information received from various clients).
So in my main process I collect this data and write it to a variable
global.sharedObject = {
Clients:[]
}
//on receiving information via ipc
global.sharedObject.Clients.push(data);
this works flawless, and gives me a array of Objects with my client status data. For example [{"id":"abe289c8-71ae-4764-87d8-1eb7b8adde7f","IP":"192.168.0.2","type":"Client Type 1","MachineName":"HP4711"}]
In my renderer process there is a page where this data is displayed live via ractive:
const remote = require('electron').remote;
let ClientList = remote.getGlobal('sharedObject').Clients;
let ractive = new Ractive({
el: '#clientBoxes',
template: myTemplate,
twoway: false,
//magic: true,
data: {
Clients: ClientList //or with same result:
Clients: remote.getGlobal('sharedObject').Clients;
});
The data is rendered correct, but only updates if I reload the page. If I use magic: true
I get a error TypeError: Cannot redefine property: id at Function.defineProperty (<anonymous>) at ...\ractive\ractive.js:10637:11
Has anyone got an idea, or knows a better way to store rapidly changing values globally in electron?
via Torf
No comments:
Post a Comment