@allgemein/eventbus
Version:
50 lines • 1.36 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AbstractEventBusAdapter = void 0;
const events_1 = require("events");
class AbstractEventBusAdapter extends events_1.EventEmitter {
constructor(nodeId, name, clazz, options) {
super();
this._subscribed = false;
this.options = options;
this.nodeId = nodeId;
this.name = name;
this.clazz = clazz;
this.getEmitter().setMaxListeners(10000);
}
getEmitter() {
return this;
}
unsubscribe() {
this.getEmitter().removeAllListeners(this.eventID());
this._subscribed = false;
}
isSubscribed() {
return this._subscribed;
}
eventID() {
return [this.nodeId, this.name].join('_');
}
shutdown() {
return this.close();
}
close() {
this.getEmitter().removeAllListeners();
const close = [];
if (this.reader) {
close.push(this.reader);
}
if (this.writer) {
close.push(this.writer);
}
if (close.length > 0) {
return Promise.all(close.map(x => x.close()));
}
return null;
}
cleanup() {
// this.
}
}
exports.AbstractEventBusAdapter = AbstractEventBusAdapter;
//# sourceMappingURL=AbstractEventBusAdapter.js.map