The results of a query on a SmartCollection Fruits
are rendered in a Meteor template. A Python script continuously insert documents in the fruit
collection.
collections/fruits.js
Fruits = new Meteor.SmartCollection('fruits');
server/publications.js
Meteor.publish('fruits', function(userId) {
return Fruits.find({}, {sort:{timestamp: -1}, limit: 30+1});
});
client/main.html
<template name="fruits">
{{#each fruit}}
{{name}} {{price}}
{{/each}}
</template>
client/main.js
Template.fruits.fruit = function() {
return Fruits.find({}, {sort:{price: -1}})
}
Question: The output of Template.fruits
appears to flicker very often, presumably when the local copy of the collection is being updated. How can we avoid the flicker?
Using Meteor v6.6.3 and smart-collection v0.3.23
Inserting documents using Python
for date, row in fruits.T.iterkv():
docExist = db.fruits.find({'timestamp': row['timestamp']})
if docExist.count() == 0:
db.fruits.insert(data)