Skip to content

Instantly share code, notes, and snippets.

@austinbv
Created February 9, 2020 03:07
Show Gist options
  • Save austinbv/629970de3cbcef99c32384e5e2f8c1da to your computer and use it in GitHub Desktop.
Save austinbv/629970de3cbcef99c32384e5e2f8c1da to your computer and use it in GitHub Desktop.
function Bar(config) {
this.config = config
}
Bar.initializeGlobalState = function() {
return new Bar(process.env.CONFIG)
}
Bar.prototype.doAThing = function() {
httpPost(config.url)
}
cost Bar = require('./Bar')
const bar = Bar.initialzeGlobalState() // Only Ever Called Once
function Foo() {
}
Foo.prototype.baz = function() {
bar.doAThing()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment