Skip to content

Instantly share code, notes, and snippets.

@WesleySmits
Last active October 22, 2022 09:20
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 WesleySmits/281f1443ff0657237e8641c880327738 to your computer and use it in GitHub Desktop.
Save WesleySmits/281f1443ff0657237e8641c880327738 to your computer and use it in GitHub Desktop.
SingletonExample - Class
export default class SingletonExample {
static #instance: SingletonExample;
public static getInstance(): SingletonExample {
if (!this.#instance) {
this.#instance = new SingletonExample();
}
return this.#instance;
}
private constructor() {}
}
// How to retrieve the instance
const instance = SingletonExample.getInstance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment