Created
March 25, 2019 16:33
-
-
Save yleflour/20c269c427ae13d76e639cf691414ebc to your computer and use it in GitHub Desktop.
Singleton Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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