Fix stores event hook up

This commit is contained in:
haad 2016-05-09 23:13:13 +02:00
parent b8e3e5397b
commit c2d2a8a6cc

View File

@ -55,17 +55,15 @@ class OrbitDB {
_subscribe(store, dbname, subscribe, callback) { _subscribe(store, dbname, subscribe, callback) {
if(subscribe === undefined) subscribe = true; if(subscribe === undefined) subscribe = true;
return store.use(this.user.username).then((events) => { store.events.on('readable', this._onSync.bind(this));
events.on('readable', this._onSync.bind(this)); store.events.on('data', this._onWrite.bind(this));
events.on('data', this._onWrite.bind(this)); store.events.on('load', this._onLoad.bind(this));
events.on('load', this._onLoad.bind(this)); store.events.on('close', this._onClose.bind(this));
events.on('close', this._onClose.bind(this));
if(subscribe) if(subscribe)
this._pubsub.subscribe(dbname, '', this._onMessage.bind(this)); this._pubsub.subscribe(dbname, '', this._onMessage.bind(this));
return; return store.use(this.user.username);
});
} }
_onMessage(dbname, message) { _onMessage(dbname, message) {