Skip to content

Instantly share code, notes, and snippets.

@yleflour
Created March 25, 2019 16:33
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 yleflour/20c269c427ae13d76e639cf691414ebc to your computer and use it in GitHub Desktop.
Save yleflour/20c269c427ae13d76e639cf691414ebc to your computer and use it in GitHub Desktop.
Singleton Pattern
class LoopbackApp {
private static instance: Promise<any>;
private constructor() {}
public static get app(): Promise<any> {
if (LoopbackApp.instance) return LoopbackApp.instance;
LoopbackApp.instance = new Promise((resolve, reject) => {
resolve();
});
return LoopbackApp.instance;
}
}
async function plop() {
const app = await LoopbackApp.app;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment