Singleton in TypeScript
Some example code on how to write a singleton in TypeScript.
/* eslint-disable no-var */
declare global {
var _singleton: SingletonClass
}
/* eslint-enable no-var */
// Only one instance for the process in production
if (!globalThis._singleton) {
...
vijayt.hashnode.dev1 min read