Cleanup of clearTimeout and nonasync funcs

This commit is contained in:
John Lindahl 2021-01-13 19:43:11 +01:00 committed by GitHub
parent 8fda4a8d61
commit 7bc4801289
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -98,7 +98,7 @@ class PlejdService extends EventEmitter {
};
clearInterval(this.pingRef);
clearInterval(this.writeQueueRef);
clearTimeout(this.writeQueueRef);
console.log('init()');
const bluez = await this.bus.getProxyObject(BLUEZ_SERVICE_NAME, '/');
@ -369,8 +369,8 @@ class PlejdService extends EventEmitter {
}
// auth done, start ping
await this.startPing();
await this.startWriteQueue();
this.startPing();
this.startWriteQueue();
// After we've authenticated, we need to hook up the event listener
// for changes to lastData.
@ -414,7 +414,7 @@ class PlejdService extends EventEmitter {
}
}
async startPing() {
startPing() {
console.log('startPing()');
clearInterval(this.pingRef);
@ -460,9 +460,9 @@ class PlejdService extends EventEmitter {
this.emit('pingSuccess', pong[0]);
}
async startWriteQueue() {
startWriteQueue() {
console.log('startWriteQueue()');
clearInterval(this.writeQueueRef);
clearTimeout(this.writeQueueRef);
this.writeQueueRef = setTimeout(() => this.runWriteQueue(), this.writeQueueWaitTime);
}