Created
February 19, 2017 22:25
-
-
Save basarat/197f38af448fe5e3f634189a3f4ccce5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const foo = require('./foo'); | |
console.log(foo.getFoo()); // hello | |
foo.setFoo('world'); | |
setTimeout(()=>{ | |
const foo = require('./foo'); // You require it again. But you get the same instance! | |
console.log(foo.getFoo()); // world | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment