User Global Variables in Custom Module keep data retained on Reload?

Hi,

What is the best practice for saving some global variables in custom modules?

I split out my custom modules into separate files for organization and structure, using require to import them. I'd like to have some variables values written into memory at the start of the app. Currently, I'm using
app.on("sessionOpened"…), and setting variables x,y,z... using a store. When the main.js custom module script reloads, the variables tend to lose their values.

Is there a specific app.on eventEmitter I should be placing my custom "global" variables I'd like to set, so that through custom module reloads they will remain in memory?

Cheers,
DMDComposer

There's no dedicated persistent global variable for this, I'll add one in a feature release, meanwhile you could hijack the app object with something like this:

app.someVar = app.someVar || 'initial_value'
1 Like

In next release there will be a global object variable to that effect.

1 Like