kadirahq / subs-manager

Subscriptions Manager for Meteor
MIT License
358 stars 36 forks source link

subs.update() #79

Open marsPure opened 8 years ago

marsPure commented 8 years ago

as you know reactive join is not going to work in publish, but there I have a work around that works for my app. for example in a publish like this: `Meteor.publish('topPostsWithTopComments', function() { var topPostsCursor = Posts.find({}, {sort: {score: -1}, limit: 30}); var userIds = topPostsCursor.map(function(p) { return p.userId });

return [ topPostCursor, Meteor.users.find({_id: {$in: userIds}}); ]; });` if before rendering posts we check for its user and if it doesn't exist in the client we just subs.clear() there won't be any issue with reactive join.

the only downside is each time I use subs.clear() the page blinks, I don't know how the internal of publish and subscribe works but is it possible to only update the subs without clearing it from minimongo and when the new info got to the client it will automatically get updated on the page without the blink.

Bandit commented 8 years ago

You need to use reset() rather than clear()

https://github.com/kadirahq/subs-manager/blob/master/lib/sub_manager.js#L199-L213