mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-12 00:56:36 +00:00
Replace async/await with Promises where possible
This commit is contained in:
parent
4f78b28cae
commit
9581b4ef31
@ -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 ++;
|
||||
|
@ -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)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user