@panyam/tsutils
Version:
Some basic TS utils for personal use
26 lines • 700 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventBus = void 0;
const events_1 = require("events");
class EventBus extends events_1.EventEmitter {
constructor() {
super();
}
static getInstance() {
if (!EventBus.instance) {
EventBus.instance = new EventBus();
}
return EventBus.instance;
}
subscribe(eventName, callback) {
this.on(eventName, callback);
}
unsubscribe(eventName, callback) {
this.removeListener(eventName, callback);
}
publish(eventName, data) {
this.emit(eventName, data);
}
}
exports.EventBus = EventBus;
//# sourceMappingURL=bus.js.map
;