Last active
March 12, 2016 08:31
-
-
Save trsdln/fb0981e296150132190d to your computer and use it in GitHub Desktop.
Simple singleton using ES6
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
class SingletonTest { | |
constructor() { | |
//intialize you singletone here | |
} | |
static getInstance() { | |
if (!SingletoneTest._instance) { | |
SingletonTest._instance = new SingletonTest(); | |
} | |
return SingletonTest._instance; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment