As David mentioned below I do needed sorting on the client so I hold on to that and tried some different directions using my publication to achieve some sort of partial reactivity on the client.
I ended up implementing a publication with an observeChanges pattern and sort on lastactivity on the client side. This publication makes sure that:
- Initially all items are send to the client (within the limit ofcourse)
- Whenever an item is changed, it removes the lastactivity field and doesnt update that but all other attributes are updated and send over to the client
- Whenever an item is added its gets a later lastactivity value then beforeLastactivity variable and thus is not added
- Increasing the limit for infinite scrolling keeps working
When a client refreshes everything is send down to the client again because beforeLastactivity gets updated
Meteor.publish('popularPicks', function(limit,beforeLastactivity) { var init = true; var self = this; if(!beforeLastactivity) var beforeLastactivity = new Date().getTime(); if(!limit) { var limit = 18; } var query = Picks.find({},{ limit: limit, sort: { lastactivity: -1 } }); var handle = query.observeChanges({ added: function( id,doc ){ if(init){ if(doc.lastactivity < beforeLastactivity) self.added( 'picks', id, doc ); } }, changed: function( id,fields ){ if(fields.lastactivity) delete fields.lastactivity; self.changed( 'picks', id, fields ); } }); var init = false; self.ready(); self.onStop( function(){ handle.stop(); }); });