mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-13 01:26:37 +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();
|
// let timer = new Timer();
|
||||||
// while(true) {
|
// while(true) {
|
||||||
// timer.start();
|
// timer.start();
|
||||||
db.add(username + totalQueries);
|
await(db.add(username + totalQueries));
|
||||||
// console.log(`${timer.stop(true)} ms`);
|
// console.log(`${timer.stop(true)} ms`);
|
||||||
totalQueries ++;
|
totalQueries ++;
|
||||||
lastTenSeconds ++;
|
lastTenSeconds ++;
|
||||||
|
@ -22,12 +22,11 @@ class Client {
|
|||||||
if(password === undefined) password = '';
|
if(password === undefined) password = '';
|
||||||
if(subscribe === undefined) subscribe = true;
|
if(subscribe === undefined) subscribe = true;
|
||||||
|
|
||||||
this.db.use(channel, this.user, password).then(() => {
|
await(this.db.use(channel, this.user, password));
|
||||||
this.db.events[channel].on('write', this._onWrite.bind(this));
|
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('sync', this._onSync.bind(this));
|
||||||
this.db.events[channel].on('load', this._onLoad.bind(this));
|
this.db.events[channel].on('load', this._onLoad.bind(this));
|
||||||
this.db.events[channel].on('loaded', this._onLoaded.bind(this));
|
this.db.events[channel].on('loaded', this._onLoaded.bind(this));
|
||||||
});
|
|
||||||
|
|
||||||
if(subscribe)
|
if(subscribe)
|
||||||
this._pubsub.subscribe(channel, password, async((channel, message) => this.db.sync(channel, message)));
|
this._pubsub.subscribe(channel, password, async((channel, message) => this.db.sync(channel, message)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user