Last active
May 8, 2018 18:09
-
-
Save rakibulalam/ca6762989777dd3e6b28962898bb72b6 to your computer and use it in GitHub Desktop.
Singleton Pattern in 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
let instance; | |
// define instance variaible out of the scope. | |
export default class Single{ | |
constructor() | |
{ | |
if(!instance) // if its not defined. | |
{ | |
instance=this; // let it to be filled. | |
} | |
return instnace; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment