From c2d2a8a6ccb3d48b284aa7b3bc9d760d7975b8c5 Mon Sep 17 00:00:00 2001 From: haad Date: Mon, 9 May 2016 23:13:13 +0200 Subject: [PATCH] Fix stores event hook up --- src/OrbitDB.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/OrbitDB.js b/src/OrbitDB.js index 9c3e30f..0ab45b5 100644 --- a/src/OrbitDB.js +++ b/src/OrbitDB.js @@ -55,17 +55,15 @@ class OrbitDB { _subscribe(store, dbname, subscribe, callback) { if(subscribe === undefined) subscribe = true; - return store.use(this.user.username).then((events) => { - events.on('readable', this._onSync.bind(this)); - events.on('data', this._onWrite.bind(this)); - events.on('load', this._onLoad.bind(this)); - events.on('close', this._onClose.bind(this)); + store.events.on('readable', this._onSync.bind(this)); + store.events.on('data', this._onWrite.bind(this)); + store.events.on('load', this._onLoad.bind(this)); + store.events.on('close', this._onClose.bind(this)); - if(subscribe) - this._pubsub.subscribe(dbname, '', this._onMessage.bind(this)); + if(subscribe) + this._pubsub.subscribe(dbname, '', this._onMessage.bind(this)); - return; - }); + return store.use(this.user.username); } _onMessage(dbname, message) {