Created
February 10, 2016 05:28
-
-
Save DragorWW/7e82f7db65afcaa229d1 to your computer and use it in GitHub Desktop.
javascript es2015 singleton patter
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
| let instances; | |
| class MyClass { | |
| constructor() { | |
| if (!instances) { | |
| instances = this; | |
| } | |
| return instances; | |
| } | |
| } | |
| export default new MyClass; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment