Skip to content

Instantly share code, notes, and snippets.

@brandonvanha
Created February 27, 2018 23:57
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 brandonvanha/1c7526b70466ecb8b53544edcb89314a to your computer and use it in GitHub Desktop.
Save brandonvanha/1c7526b70466ecb8b53544edcb89314a to your computer and use it in GitHub Desktop.
class MyClass
{
private static _instance: MyClass;
private constructor()
{
//...
}
public static get Instance()
{
// Do you need arguments? Make it a regular method instead.
return this._instance || (this._instance = new this());
}
}
const myClassInstance = MyClass.Instance;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment