Replace async/await with Promises where possible

This commit is contained in:
haad 2016-04-08 08:56:56 +02:00
parent 4f78b28cae
commit 9581b4ef31
2 changed files with 6 additions and 7 deletions

View File

@ -50,7 +50,7 @@ let run = (async(() => {
// let timer = new Timer();
// while(true) {
// timer.start();
db.add(username + totalQueries);
await(db.add(username + totalQueries));
// console.log(`${timer.stop(true)} ms`);
totalQueries ++;
lastTenSeconds ++;

View File

@ -22,12 +22,11 @@ class Client {
if(password === undefined) password = '';
if(subscribe === undefined) subscribe = true;
this.db.use(channel, this.user, password).then(() => {
this.db.events[channel].on('write', this._onWrite.bind(this));
this.db.events[channel].on('sync', this._onSync.bind(this));
this.db.events[channel].on('load', this._onLoad.bind(this));
this.db.events[channel].on('loaded', this._onLoaded.bind(this));
});
await(this.db.use(channel, this.user, password));
this.db.events[channel].on('write', this._onWrite.bind(this));
this.db.events[channel].on('sync', this._onSync.bind(this));
this.db.events[channel].on('load', this._onLoad.bind(this));
this.db.events[channel].on('loaded', this._onLoaded.bind(this));
if(subscribe)
this._pubsub.subscribe(channel, password, async((channel, message) => this.db.sync(channel, message)));