Use of the settings.write function

Hello,

Is there a way to use the settings.write function to add my own properties in the settings file and access them through all the components within the session without being persisted?

PS If I ask this is because it gives me an errore settings.write is not a function

thanks
Marco

settings.write is not exposed in the custom module currently. Using a simple module to store your settings should be more appropriate (and if you need persistence, using node's fs module will let you write on the filesystem).

While writing this I found out that calling require() doesn't allow sharing a module accross different modules (it's read from disk and executed each time), I'm pushing a fix to make this possible :

// settings.js
module.exports = {}

// module-a.js
var settings = require('./settings.js')
settings.x = 1
require('./module-b.js')

// module-b.js
var settings = require('./settings.js')
console.log(settings.x)

1 Like