mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-05-22 06:46:38 +00:00
Cleanup
This commit is contained in:
parent
7d7a2df631
commit
34ae809b0c
@ -22,7 +22,7 @@ class OrbitClient {
|
|||||||
if(subscribe === undefined) subscribe = true;
|
if(subscribe === undefined) subscribe = true;
|
||||||
|
|
||||||
this.db.use(channel, this.user, password);
|
this.db.use(channel, this.user, password);
|
||||||
this.db.events.on('data', (hash) => this._pubsub.publish(channel, hash));
|
this.db.events.on('write', this._onUpdated.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)));
|
||||||
@ -48,6 +48,11 @@ class OrbitClient {
|
|||||||
this.network = null;
|
this.network = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_onUpdated(channel, hash) {
|
||||||
|
this._pubsub.publish(channel, hash)
|
||||||
|
this.events.emit('data', channel, hash);
|
||||||
|
}
|
||||||
|
|
||||||
_iterator(channel, password, options) {
|
_iterator(channel, password, options) {
|
||||||
const messages = this.db.query(channel, password, options);
|
const messages = this.db.query(channel, password, options);
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
|
@ -4,7 +4,6 @@ const Lazy = require('lazy.js');
|
|||||||
const EventEmitter = require('events').EventEmitter;
|
const EventEmitter = require('events').EventEmitter;
|
||||||
const async = require('asyncawait/async');
|
const async = require('asyncawait/async');
|
||||||
const await = require('asyncawait/await');
|
const await = require('asyncawait/await');
|
||||||
const ipfsAPI = require('orbit-common/lib/ipfs-api-promised');
|
|
||||||
const OrbitList = require('./list/OrbitList');
|
const OrbitList = require('./list/OrbitList');
|
||||||
const Operation = require('./db/Operation');
|
const Operation = require('./db/Operation');
|
||||||
const OpTypes = require('./db/OpTypes');
|
const OpTypes = require('./db/OpTypes');
|
||||||
@ -106,7 +105,7 @@ class OrbitDB {
|
|||||||
// Write an op to the db
|
// Write an op to the db
|
||||||
_write(channel, password, operation, key, value, data) {
|
_write(channel, password, operation, key, value, data) {
|
||||||
const hash = await(Operation.create(this._ipfs, this._logs[channel], this.user, operation, key, value));
|
const hash = await(Operation.create(this._ipfs, this._logs[channel], this.user, operation, key, value));
|
||||||
this.events.emit('data', hash);
|
this.events.emit('write', channel, hash);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const io = require('socket.io-client');
|
const io = require('socket.io-client');
|
||||||
|
|
||||||
class Pubsub {
|
class Pubsub {
|
||||||
constructor(ipfs) {
|
constructor(ipfs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user