I'm new in Node.js and I wondering something. I'm use express and socket.io. there is some value to should be changeable, let's say this 'flag' that have boolean type variable - this is 'false' at default.
but some moment especially when I click some button, it would be change to 'true'. the express and socket.io workflow is fine, but I don't know how to modifying variable from different file not just copying it.
Please see below code to understand
Main.js
var flag = false;
exports.flag = flag;
// display flag every second
setInterval((function(){console.log(flag)}), 1000);
Remote.js
// I want to change 'original flag' at main.js in remote.js
// How can I do that? I think below is just copying it, so doesn't effect to main.js
flag = require('/Main').flag;
// the flag will be 'true' after some moment
flag = true;
expected result I want in main.js
false
false
false
...
true
true
How can I do that?