Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subs.update() #79

Open
marsPure opened this issue Jul 4, 2016 · 1 comment
Open

subs.update() #79

marsPure opened this issue Jul 4, 2016 · 1 comment

Comments

@marsPure
Copy link

marsPure commented Jul 4, 2016

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
Copy link

Bandit commented Aug 29, 2016

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants