Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class SingletonPattern {
  2. private static instance: SingletonPattern
  3. static getInstance() {
  4. if (!SingletonPattern.instance) {
  5. SingletonPattern.instance = new SingletonPattern()
  6. }
  7. return SingletonPattern.instance
  8. }
  9. private constructor() { }
  10.  
  11. private propOne = 1
  12. private propTwo = 1
  13.  
  14.  
  15. methodOne() {
  16. return this.propOne
  17. }
  18.  
  19. methodTwo() {
  20. return this.propTwo
  21. }
  22. }
  23.  
  24. export default SingletonPattern.getInstance()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement