I am trying to understand when I might use this.flush() in a Meteor application.
The docs state the following
Call inside publish function. Sends all the pending set, unset, and
complete messages to the client.
If my publish function is something like this
Meteor.publish('myCollection', function(myid){
return MyCollection.find({_id: myid});
});
would I use this.flush()?
What kind of case would one use this.flush() in?
Thanks
S
Not needed in that use case, because
Meteor.publishautomatically handles the details of how to turn Mongo cursors into the appropriatesetandunsetcommands for each subscribed client.If you write a custom publish that manages its own
setandunset, you can useflushto push all pending changes down to the client. You’ll find an example of that technique here: How does the messages-count example in Meteor docs work?