Skip to content

Commit

Permalink
Merge pull request #53 from salomonelli/master
Browse files Browse the repository at this point in the history
FIX bug #52 query.$ fires on remove
  • Loading branch information
pubkey authored Feb 12, 2017
2 parents b92521e + 032b4ea commit 533f86d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RxQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class RxQuery {
this._subject = new util.Rx.BehaviorSubject(null);
this._obsRunning = false;
const collection$ = this.collection.$
.filter(cEvent => ['RxCollection.insert', 'RxDocument.save'].includes(cEvent.data.op))
.filter(cEvent => ['RxCollection.insert', 'RxDocument.save', 'RxDocument.remove'].includes(cEvent.data.op))
.startWith(1)
.filter(x => !this._obsRunning)
.do(x => this._obsRunning = true)
Expand Down
25 changes: 25 additions & 0 deletions test/node/Observe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,31 @@ describe('Observe.test.js', () => {
});
});
});
describe('.remove()', () => {
describe('positive', () => {
it('should fire on remove', async() => {
const db = await RxDatabase.create(randomToken(10), memdown);
const colName = randomToken(10);
const c = await db.collection(colName, schemas.human);
let ar = [];
const sub = c
.find()
.$
.subscribe(docs => ar.push(docs));

await util.promiseWait(10);
await c.insert(schemaObjects.human());
await util.promiseWait(10);
assert.equal(ar.length, 3);
const doc = await c.findOne().exec();
await doc.remove();
await util.promiseWait(10);
assert.equal(ar.length, 4);
sub.unsubscribe();
db.destroy();
});
});
});
});
describe('Document', () => {
describe('.save()', () => {
Expand Down

0 comments on commit 533f86d

Please sign in to comment.