Fix issue where BufferedEmitter would not deliver buffered events

This commit is contained in:
Alex Dima
2019-08-26 11:18:40 +02:00
parent 0cf92dcf52
commit 185308c0dd
+6 -2
View File
@@ -420,7 +420,7 @@ export class BufferedEmitter<T> {
// it is important to deliver these messages after this call, but before
// other messages have a chance to be received (to guarantee in order delivery)
// that's why we're using here nextTick and not other types of timeouts
process.nextTick(() => this._deliverMessages);
process.nextTick(() => this._deliverMessages());
},
onLastListenerRemove: () => {
this._hasListeners = false;
@@ -443,7 +443,11 @@ export class BufferedEmitter<T> {
public fire(event: T): void {
if (this._hasListeners) {
this._emitter.fire(event);
if (this._bufferedMessages.length > 0) {
this._bufferedMessages.push(event);
} else {
this._emitter.fire(event);
}
} else {
this._bufferedMessages.push(event);
}