Skip to content

Instantly share code, notes, and snippets.

@basarat
Created February 19, 2017 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basarat/197f38af448fe5e3f634189a3f4ccce5 to your computer and use it in GitHub Desktop.
Save basarat/197f38af448fe5e3f634189a3f4ccce5 to your computer and use it in GitHub Desktop.
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