I have a Python script that sends 3000 rows to a Meteor MongoDB collection, and after a few minutes, deletes all the documents inside the collection, and then re-uploads 3000 documents. This process repeats every few minutes.
On my UI, I have a table displaying all 3000 documents and a text box showing the count of documents (i.e. “3000”). The UI isn’t fast enough to render this when the Python script executes and makes changes to the database. Because of this, the text box goes from 0 to 260 to 500 to 1600 to 3000 (since it takes some time to load up 3000 rows in the table). Is there a way I can either:
Prevent the text box from showing intermediate database changes, i.e. it should go from 0 straight to 3000.
Prevent the UI from rendering at all until all 3000 rows/documents are deleted and re-uploaded.
I read something about ready() but don’t know how to implement that. Thanks.
Use Tracker.Autorun(). As you might have read, .ready() will return true after all the documents are loaded in miniMongo. So you can show the count or docs list after it returns true.
const handle = Meteor.subscribe('docs.list');
Tracker.autorun(() => {
const isReady = handle.ready();
if (isReady) {
let docs = Collection.docs.find();
// pass data (docs) to ui after subscription is ready
}
});
Meteor.subscribe('getlogins');
Template.loginstemplate.helpers({
'ready': function () {
return Template.instance().subscriptionsReady();
},
It does wait for the subscription to to be ready, however, the counter doesn’t go from 0 to 3000 instantly, since it’s the rendering that takes time. Is there any “don’t show changes until render complete” kind of function in Meteor? @harikrishna9@Chris.R