Created
November 22, 2021 16:21
-
-
Save clintonmedbery/3b2c3a730bafc7abe066feaaff87aa2f to your computer and use it in GitHub Desktop.
Example of a async singleton class
This file contains hidden or 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
export class TestServer { | |
static _instance: TestServer; | |
static app: Thing; | |
constructor() { | |
return (async () => { | |
if (TestServer._instance) { | |
return TestServer._instance; | |
} | |
const app = await Something(); | |
TestServer.app = app; | |
TestServer._instance = this; | |
return this; | |
})(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment