The wonders of Singletons
I love singletons.
It's a great way to prevent multiple instances of the same object.
Think about it...
DO you really need 10 different user connections? No.
Do you want 5 different logging systems all writing to different files? No.
Instead, create one instance – the single source of truth and everything points back to it.
Simple.
Efficient.
Clear.
These patterns come in really useful with like DB connections, loggers, and probably configs.
2
4 comments
Ruben Leija
5
The wonders of Singletons
JavaScript
skool.com/javascript
Chat about javascript and javascript related projects. Yes, typescript counts.
Leaderboard (30-day)
Powered by