Skip to content

Commit

Permalink
7.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Nov 21, 2017
1 parent 71a6124 commit 796ab66
Show file tree
Hide file tree
Showing 51 changed files with 2,154 additions and 4,485 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changelog

## X.X.X (coming soon)
## 7.1.0 (November 22, 2017)

Other:
- Reduced build-size by using [rxjs-lettable-operators](https://github.com/ReactiveX/rxjs/blob/master/doc/lettable-operators.md). Read [this](https://github.com/pubkey/rxdb/blob/master/docs-src/install.md#rxjs) if you have problems.
Expand Down
7 changes: 4 additions & 3 deletions dist/es/data-migrator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import PouchDB from './pouch-db';
import clone from 'clone';

import * as util from './util';
import RxSchema from './rx-schema';
import Crypter from './crypter';
import RxError from './rx-error';
import overwritable from './overwritable';
import hooks from './hooks';

import { Observable } from 'rxjs/Observable';

var DataMigrator = function () {
function DataMigrator(newestCollection, migrationStrategies) {
_classCallCheck(this, DataMigrator);
Expand Down Expand Up @@ -76,7 +77,7 @@ var DataMigrator = function () {
percent: 0 // percentage
};

var migrationState$ = new util.Rx.Observable(function () {
var migrationState$ = new Observable(function () {
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(observer) {
var oldCols, countAll, totalCount, currentCol, _loop;

Expand Down Expand Up @@ -444,7 +445,7 @@ var OldCollection = function () {
if (this._migrate) throw new Error('migration already running');
this._migrate = true;

var stateStream$ = new util.Rx.Observable(function () {
var stateStream$ = new Observable(function () {
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(observer) {
var batch, error;
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
Expand Down
10 changes: 6 additions & 4 deletions dist/es/plugins/attachments.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ import IdleQueue from 'custom-idle-queue';
import RxChangeEvent from './../rx-change-event';
import * as util from './../util';

import { map } from 'rxjs/operators/map';

/**
* to not have update-conflicts,
* we use atomic inserts (per document) on putAttachment()
Expand Down Expand Up @@ -460,18 +462,18 @@ export var prototypes = {
get: function allAttachments$() {
var _this3 = this;

return this._dataSync$.map(function (data) {
return this._dataSync$.pipe(map(function (data) {
if (!data._attachments) return {};
return data._attachments;
}).map(function (attachmentsData) {
}), map(function (attachmentsData) {
return Object.entries(attachmentsData);
}).map(function (entries) {
}), map(function (entries) {
return entries.map(function (entry) {
var id = entry[0];
var attachmentData = entry[1];
return RxAttachment.fromPouchDocument(id, attachmentData, _this3);
});
});
}));
}
});
}
Expand Down
4 changes: 3 additions & 1 deletion dist/es/plugins/in-memory.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import _inherits from 'babel-runtime/helpers/inherits';
* So you can do faster queries and also query over encrypted fields
*/

import { Subject } from 'rxjs/Subject';

import RxCollection from '../rx-collection';
import Core from '../core';
import * as util from '../util';
Expand Down Expand Up @@ -70,7 +72,7 @@ export var InMemoryRxCollection = function (_RxCollection$RxColle) {

this.pouch = new PouchDB('rxdb-in-memory-' + util.randomCouchString(10), util.adapterObject('memory'), {});

this._observable$ = new util.Rx.Subject();
this._observable$ = new Subject();
this._changeEventBuffer = ChangeEventBuffer.create(this);

// INDEXES
Expand Down
52 changes: 28 additions & 24 deletions dist/es/plugins/leader-election.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import RxBroadcastChannel from '../rx-broadcast-channel';

export var documentID = '_local/leader';

import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { filter } from 'rxjs/operators/filter';
import { first } from 'rxjs/operators/first';

/**
* This time defines how 'fast' the communication between the instances is.
* If this time is too low, it's possible that more than one instance becomes leader
Expand All @@ -34,7 +38,7 @@ var LeaderElector = function () {
this.token = this.database.token;

this.isLeader = false;
this.becomeLeader$ = new util.Rx.BehaviorSubject({
this.becomeLeader$ = new BehaviorSubject({
isLeader: false
});

Expand Down Expand Up @@ -308,37 +312,37 @@ var LeaderElector = function () {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
subs.push(_this.bc.$.filter(function () {
subs.push(_this.bc.$.pipe(filter(function () {
return !!_this.isApplying;
}).filter(function (msg) {
}), filter(function (msg) {
return msg.t >= applyTime;
}).filter(function (msg) {
}), filter(function (msg) {
return msg.type === 'apply';
}).filter(function (msg) {
}), filter(function (msg) {
if (msg.data < applyTime || msg.data === applyTime && msg.it > _this.token) return true;else return false;
}).filter(function () {
}), filter(function () {
return errors.length < 1;
}).subscribe(function (msg) {
})).subscribe(function (msg) {
return errors.push('other is applying:' + msg.it);
}));
subs.push(_this.bc.$.filter(function () {
subs.push(_this.bc.$.pipe(filter(function () {
return !!_this.isApplying;
}).filter(function (msg) {
}), filter(function (msg) {
return msg.t >= applyTime;
}).filter(function (msg) {
}), filter(function (msg) {
return msg.type === 'tell';
}).filter(function () {
}), filter(function () {
return errors.length < 1;
}).subscribe(function (msg) {
})).subscribe(function (msg) {
return errors.push('other is leader' + msg.it);
}));
subs.push(_this.bc.$.filter(function () {
subs.push(_this.bc.$.pipe(filter(function () {
return !!_this.isApplying;
}).filter(function (msg) {
}), filter(function (msg) {
return msg.type === 'apply';
}).filter(function (msg) {
}), filter(function (msg) {
if (msg.data > applyTime || msg.data === applyTime && msg.it > _this.token) return true;else return false;
}).subscribe(function () {
})).subscribe(function () {
return _this.bc.write('apply', applyTime);
}));

Expand Down Expand Up @@ -550,13 +554,13 @@ var LeaderElector = function () {
break;

case 11:
this.signalLeadership = this.bc.$.filter(function () {
this.signalLeadership = this.bc.$.pipe(filter(function () {
return !!_this2.isLeader;
})
}),
// BUGFIX: avoids loop-hole when for whatever reason 2 are leader
.filter(function (msg) {
filter(function (msg) {
return msg.type !== 'tell';
}).subscribe(function () {
})).subscribe(function () {
return _this2.leaderSignal();
});
this.subs.push(this.signalLeadership);
Expand Down Expand Up @@ -758,9 +762,9 @@ var LeaderElector = function () {

case 9:
// apply when leader dies
this.subs.push(this.bc.$.filter(function (msg) {
this.subs.push(this.bc.$.pipe(filter(function (msg) {
return msg.type === 'death';
}).subscribe(function () {
})).subscribe(function () {
return _this3.applyOnce();
}));
return _context11.abrupt('break', 13);
Expand Down Expand Up @@ -822,9 +826,9 @@ var LeaderElector = function () {
}))();

case 14:
return _context11.abrupt('return', this.becomeLeader$.asObservable().filter(function (i) {
return _context11.abrupt('return', this.becomeLeader$.asObservable().pipe(filter(function (i) {
return i.isLeader === true;
}).first().toPromise());
}), first()).toPromise());

case 15:
case 'end':
Expand Down
6 changes: 4 additions & 2 deletions dist/es/plugins/local-documents.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import RxChangeEvent from '../rx-change-event';
import DocCache from '../doc-cache';
import RxError from '../rx-error';

import { filter } from 'rxjs/operators/filter';

var DOC_CACHE_BY_PARENT = new WeakMap();
var _getDocCache = function _getDocCache(parent) {
if (!DOC_CACHE_BY_PARENT.has(parent)) {
Expand All @@ -31,9 +33,9 @@ var _getDocCache = function _getDocCache(parent) {
var CHANGE_SUB_BY_PARENT = new WeakMap();
var _getChangeSub = function _getChangeSub(parent) {
if (!CHANGE_SUB_BY_PARENT.has(parent)) {
var sub = parent.$.filter(function (cE) {
var sub = parent.$.pipe(filter(function (cE) {
return cE.data.isLocal;
}).subscribe(function (cE) {
})).subscribe(function (cE) {
var docCache = _getDocCache(parent);
var doc = docCache.get(cE.data.doc);
if (doc) doc._handleChangeEvent(cE);
Expand Down
50 changes: 28 additions & 22 deletions dist/es/plugins/replication.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ import _classCallCheck from 'babel-runtime/helpers/classCallCheck';

import clone from 'clone';
import PouchReplicationPlugin from 'pouchdb-replication';
import { Subject } from 'rxjs/Subject';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { filter } from 'rxjs/operators/filter';
import { map } from 'rxjs/operators/map';
import { delay } from 'rxjs/operators/delay';

import * as util from '../util';
import Core from '../core';
Expand All @@ -27,11 +33,11 @@ export var RxReplicationState = function () {
this.collection = collection;
this._pouchEventEmitterObject = null;
this._subjects = {
change: new util.Rx.Subject(),
docs: new util.Rx.Subject(),
active: new util.Rx.BehaviorSubject(false),
complete: new util.Rx.BehaviorSubject(false),
error: new util.Rx.Subject()
change: new Subject(),
docs: new Subject(),
active: new BehaviorSubject(false),
complete: new BehaviorSubject(false),
error: new Subject()
};

// create getters
Expand All @@ -51,12 +57,12 @@ export var RxReplicationState = function () {
this._pouchEventEmitterObject = evEmitter;

// change
this._subs.push(util.Rx.Observable.fromEvent(evEmitter, 'change').subscribe(function (ev) {
this._subs.push(fromEvent(evEmitter, 'change').subscribe(function (ev) {
return _this2._subjects.change.next(ev);
}));

// docs
this._subs.push(util.Rx.Observable.fromEvent(evEmitter, 'change').subscribe(function (ev) {
this._subs.push(fromEvent(evEmitter, 'change').subscribe(function (ev) {
if (_this2._subjects.docs.observers.length === 0 || ev.direction !== 'pull') return;

ev.change.docs.filter(function (doc) {
Expand All @@ -71,20 +77,20 @@ export var RxReplicationState = function () {
}));

// error
this._subs.push(util.Rx.Observable.fromEvent(evEmitter, 'error').subscribe(function (ev) {
this._subs.push(fromEvent(evEmitter, 'error').subscribe(function (ev) {
return _this2._subjects.error.next(ev);
}));

// active
this._subs.push(util.Rx.Observable.fromEvent(evEmitter, 'active').subscribe(function () {
this._subs.push(fromEvent(evEmitter, 'active').subscribe(function () {
return _this2._subjects.active.next(true);
}));
this._subs.push(util.Rx.Observable.fromEvent(evEmitter, 'paused').subscribe(function () {
this._subs.push(fromEvent(evEmitter, 'paused').subscribe(function () {
return _this2._subjects.active.next(false);
}));

// complete
this._subs.push(util.Rx.Observable.fromEvent(evEmitter, 'complete').subscribe(function (info) {
this._subs.push(fromEvent(evEmitter, 'complete').subscribe(function (info) {
return _this2._subjects.complete.next(info);
}));
};
Expand Down Expand Up @@ -137,38 +143,38 @@ export function watchForChanges() {
* this is to ensure that changes from 'synced' dbs will be published
*/
var sendChanges = {};
var pouch$ = util.Rx.Observable.fromEvent(this.pouch.changes({
var pouch$ = fromEvent(this.pouch.changes({
since: 'now',
live: true,
include_docs: true
}), 'change').filter(function (c) {
}), 'change').pipe(filter(function (c) {
return c.id.charAt(0) !== '_';
}).map(function (c) {
}), map(function (c) {
return c.doc;
}).filter(function (doc) {
}), filter(function (doc) {
return !_this3._changeEventBuffer.buffer.map(function (cE) {
return cE.data.v._rev;
}).includes(doc._rev);
}).filter(function (doc) {
}), filter(function (doc) {
return sendChanges[doc._rev] = 'YES';
}).delay(10).map(function (doc) {
}), delay(10), map(function (doc) {
var ret = null;
if (sendChanges[doc._rev] === 'YES') ret = doc;
delete sendChanges[doc._rev];
return ret;
}).filter(function (doc) {
}), filter(function (doc) {
return doc !== null;
}).subscribe(function (doc) {
})).subscribe(function (doc) {
_this3.$emit(RxChangeEvent.fromPouchChange(doc, _this3));
});

this._subs.push(pouch$);

var ob2 = this.$.map(function (cE) {
var ob2 = this.$.pipe(map(function (cE) {
return cE.data.v;
}).map(function (doc) {
}), map(function (doc) {
if (doc && sendChanges[doc._rev]) sendChanges[doc._rev] = 'NO';
}).subscribe();
})).subscribe();
this._subs.push(ob2);

this.synced = true;
Expand Down
12 changes: 7 additions & 5 deletions dist/es/rx-broadcast-channel.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
import _createClass from 'babel-runtime/helpers/createClass';
import * as util from './util';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { map } from 'rxjs/operators/map';
import { filter } from 'rxjs/operators/filter';

/**
* this is a wrapper for BroadcastChannel to integrate it with RxJS
Expand Down Expand Up @@ -59,13 +61,13 @@ var RxBroadcastChannel = function () {
var _this = this;

if (!this._$) {
this._$ = util.Rx.Observable.fromEvent(this.bc, 'message').map(function (msg) {
this._$ = fromEvent(this.bc, 'message').pipe(map(function (msg) {
return msg.data;
}).map(function (strMsg) {
}), map(function (strMsg) {
return JSON.parse(strMsg);
}).filter(function (msg) {
}), filter(function (msg) {
return msg.it !== _this.token;
});
}));
}
return this._$;
}
Expand Down
Loading

0 comments on commit 796ab66

Please sign in to comment.