Singleton : Design Patterns in TypeScript

Singleton : Design Patterns in TypeScript

Channel:
Subscribers:
25,200
Published on ● Video Link: https://www.youtube.com/watch?v=yg3gt-SZGQY



Duration: 3:49
0 views
1


Design Patterns In TypeScript (book)
https://www.amazon.com/dp/B0948BCH24 : ASIN B0948BCH24
https://www.amazon.com/dp/B094716FD6 : ASIN B094716FD6

Documentation : https://sbcode.net/typescript/singleton/

Sometimes you need an object in an application where there is only one instance.

You don't want there to be many versions, for example, you have a game with a score and you want to adjust it. You may have accidentally created several instances of the class holding the score object. Or, you may be opening a database connection, there is no need to create many, when you can use the existing one that is already in memory. You may want a logging component, and you want to ensure all classes use the same instance. So, every class could declare their own logger component, but behind the scenes, they all point to the same memory address.

By creating a class and following the Singleton pattern, you can enforce that even if any number of instances were created, they will still refer to the original class.

#singletonPattern
#typescriptSingleton
#singletonPatternTypescript







Tags:
Design Patterns In TypeScript
TypeScript
Design Patterns
singleton
singleton pattern