@hastehaul/common 3.12.0 → 3.13.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
|
|
1
1
|
import { EventEmitter } from 'events';
|
2
|
-
declare class SingletonEventEmitter {
|
3
|
-
private _instance
|
4
|
-
|
5
|
-
|
2
|
+
declare class SingletonEventEmitter extends EventEmitter {
|
3
|
+
private static _instance;
|
4
|
+
private constructor();
|
5
|
+
static get instance(): SingletonEventEmitter;
|
6
6
|
}
|
7
7
|
export declare const emitterWrapper: SingletonEventEmitter;
|
8
8
|
export {};
|
@@ -2,14 +2,16 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.emitterWrapper = void 0;
|
4
4
|
const events_1 = require("events");
|
5
|
-
class SingletonEventEmitter {
|
6
|
-
|
7
|
-
|
8
|
-
throw new Error("Can not access EVENT EMITTER client before connecting");
|
9
|
-
return this._instance;
|
5
|
+
class SingletonEventEmitter extends events_1.EventEmitter {
|
6
|
+
constructor() {
|
7
|
+
super();
|
10
8
|
}
|
11
|
-
|
12
|
-
this._instance
|
9
|
+
static get instance() {
|
10
|
+
if (!this._instance) {
|
11
|
+
this._instance = new SingletonEventEmitter();
|
12
|
+
}
|
13
|
+
return this._instance;
|
13
14
|
}
|
14
15
|
}
|
15
|
-
|
16
|
+
// Export the singleton instance
|
17
|
+
exports.emitterWrapper = SingletonEventEmitter.instance;
|