From 38b1663755e45d497f418e9e13ad9d7b4b66752e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Fri, 24 Jan 2020 11:28:33 +0100 Subject: [PATCH] EventIndex: Subclass the event emitter instead of putting one in a property. --- src/indexing/EventIndex.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/indexing/EventIndex.js b/src/indexing/EventIndex.js index 53f47148b9..85e75cfc82 100644 --- a/src/indexing/EventIndex.js +++ b/src/indexing/EventIndex.js @@ -22,8 +22,9 @@ import {EventEmitter} from "events"; /* * Event indexing class that wraps the platform specific event indexing. */ -export default class EventIndex { +export default class EventIndex extends EventEmitter { constructor() { + super(); this.crawlerCheckpoints = []; // The time in ms that the crawler will wait loop iterations if there // have not been any checkpoints to consume in the last iteration. @@ -35,7 +36,6 @@ export default class EventIndex { this._crawler = null; this._currentCheckpoint = null; this.liveEventsForIndex = new Set(); - this._eventEmitter = new EventEmitter(); } async init() { @@ -188,7 +188,7 @@ export default class EventIndex { } emitNewCheckpoint() { - this._eventEmitter.emit("changedCheckpoint", this.currentRoom()); + this.emit("changedCheckpoint", this.currentRoom()); } async crawlerFunc() { @@ -459,12 +459,4 @@ export default class EventIndex { return client.getRoom(this.crawlerCheckpoints[0].roomId); } } - - on(eventName, callback) { - this._eventEmitter.on(eventName, callback); - } - - removeListener(eventName, callback) { - this._eventEmitter.removeListener(eventName, callback); - } }