diff --git a/lib/client/ground.db.js b/lib/client/ground.db.js index 050f25a..54a2a20 100644 --- a/lib/client/ground.db.js +++ b/lib/client/ground.db.js @@ -44,9 +44,9 @@ function strId(id) { } function throttle(func, timeFrame) { - var lastTime = 0; + let lastTime = 0; return function () { - var now = new Date(); + const now = new Date(); if (now - lastTime >= timeFrame) { func(); lastTime = now; @@ -59,13 +59,12 @@ function throttle(func, timeFrame) { */ const Invalidate = (collection, wait=100) => { return throttle(() => { - Object.keys(collection._collection.queries) - .forEach(qid => { + for (const qid of Object.keys(collection._collection.queries)) { const query = collection._collection.queries[qid]; if (query) { collection._collection._recomputeResults(query); } - }); + } collection._collection._observeQueue.drain(); }, wait); }; @@ -166,7 +165,7 @@ Ground.Collection = class GroundCollection { this.pendingReads.dec(); - // Check if all documetns have been handled + // Check if all documents have been handled if (++handled === len) { Kernel.defer(() => { this.isLoaded = true; @@ -208,7 +207,7 @@ Ground.Collection = class GroundCollection { }); } else { this.storage - .setItem(doc._id, EJSON.toJSONValue(doc)) + .setItem(doc._id, EJSON.toJSONValue(doc.getDocument?.() || doc)) .then(() => { this.pendingWrites.dec(); }); @@ -376,8 +375,8 @@ Ground.Collection = class GroundCollection { Meteor.defer(() => { pendingOnLoad.forEach(f => { f(); - }) - }) + }); + }); } } diff --git a/package.js b/package.js index 20e1e35..ce4f722 100644 --- a/package.js +++ b/package.js @@ -10,7 +10,7 @@ Npm.depends({ }); Package.onUse(function (api) { - api.versionsFrom(['1.3', '2.3']); + api.versionsFrom(['3.0-rc.4']); api.use(['ecmascript', 'mongo-id', 'reactive-var', 'diff-sequence', 'minimongo']); api.use([