Test OrbitDB, refactor to use promises

This commit is contained in:
haad
2016-04-12 18:15:31 +02:00
parent 3da2dbcad6
commit 5aa8d3e384
7 changed files with 769 additions and 541 deletions

View File

@@ -23,14 +23,14 @@ class Client {
if(password === undefined) password = '';
if(subscribe === undefined) subscribe = true;
await(this.db.use(channel, this.user, password));
await(this.db.use(channel, this.user));
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)));
this._pubsub.subscribe(channel, password, async((channel, message) => await(this.db.sync(channel, message))));
return {
iterator: (options) => this._iterator(channel, password, options),