why is meteor Tracker.autorun() detects mongodb changes with a delay, if the collection was modified outside of the meteor application -
a scenario: in local meteor (v 1.2.1) development environment (webstorm), autopublish, , insecure enabled, have single mongodbdb (v 3.0.4) collection 'letters'. wish respond documents being added, removed, or modified in collection.
for purpose, have following autorun function:
template.diagram.rendered = function(){ tracker.autorun(function () { letters.find({}).observe({ added: function(document) { console.log('a new document has been added'); }, changed: function(newdocument) { console.log('a document has been changed'); }, removed: function(document) { console.log('a document has been removed'); } }); }) }
when new document added within same application, can see console messages right away (meteor latency compensation). however, when connect same mongodb database using external tool (robomongo), , add, change, or remove document within 'letters' collection - takes 6-10 seconds before change detected, , corresponding console message appears in browser. why take long, instead of being instantaneous?
once have question posted on meteor forums, pointed meteor blog post 2014, describes oplog tailing feature, , fact, on default in dev instance. made me realize, that, using mongo_url env variable dev application, forcing meteor app work mongodb instance, running on mac time, independently meteor development, and, such, considered "production" meteor app. once have switched app work ad-hock mongo connection / db, oplog tailing went effect, , started see immediate event propagation browser. thanks, @dburles meteor forums!
Comments
Post a Comment