-
-
Save dkolb/6731361 to your computer and use it in GitHub Desktop.
Node.js Module Globals Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var b = require(__dirname + "/b"), | |
c = require(__dirname + "/c"); | |
b.doIt(); | |
console.log(c.get()); //Outputs 'b.doIt is updating stuff!' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var c = require(__dirname + '/c'); | |
module.exports.doIt = function() { | |
c.update("b.doIt is updating stuff!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x; | |
module.exports.update = function(y) { | |
x = y; | |
} | |
module.exports.get = function() { | |
return x; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment