It took a while to actually understand, but this is exactly what is intended for the low-level publishing API . Read the section โAlternatively, the publish function may ...โ down, and it should be pretty clear how you send only added messages for truly new documents. Or provide a simple example:
Both server and client:
MyData = new Meteor.Collection("mydata");
Customer:
Meteor.subscribe('myPub', myFilter);
Server:
Meteor.publish('myPub', function(filter) { var self = this; var initializing = true; var handle = MyData.find(filter).observeChanges({ added: function (id, fields) { if (!initializing) self.added("mydata", id, fields); }, changed: function(id, fields) { self.changed("mydata", id, fields); }, removed: function (id) { self.removed("mydata", id); } }); initializing = false; self.ready(); self.onStop(function () { handle.stop();
UPDATE
This is so fundamental that I actually wrote a blog post about it.
source share