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

Subscriptions accumulate when rerun #13

Open
jacobparis opened this issue May 21, 2016 · 3 comments
Open

Subscriptions accumulate when rerun #13

jacobparis opened this issue May 21, 2016 · 3 comments

Comments

@jacobparis
Copy link

In a normal setting, I can set up a simple autorun loop and reactively update a subscription, for example to increase a limit.

Meteor.autorun(function () {
  var limit = Session.get('postLimit'); //Default at 5

  Meteor.subscribe('threads', limit);
});

and with a regular publication this works great. If I change postLimit to 6, one additional post will appear increasing the total posts on screen to 6.

However if I unblock the publication, it is now executing asynchronously which causes the subscriptions to pile up every time I change the limit, leaving something that simulates

Meteor.subscribe('threads', 5);
Meteor.subscribe('threads', 6);
Meteor.subscribe('threads', 7);

Which on its own wouldn't be the worst thing in the world, but the results are not merged. The above example would occur if I were to set the postLimit (which starts at 5) to 6, and then to 7. Instead of displaying 7 posts, it displays 18, like so.

A
B
C
D
E
A
B
C
D
E
F
A
B
C
D
E
F
G

A similar effect was documented in the blog post I'll link to below. He ran into this problem using lodash debounce.
http://blog.east5th.co/2015/01/19/the-dangers-of-debouncing-meteor-subscriptions/

@brg8
Copy link

brg8 commented Sep 18, 2016

Having the same problem. Any update?

@jacobparis
Copy link
Author

I forget exactly why I figured it was happening, but I stopped unblocking
the publication to avoid the problem. I think it detached the content from
the subscription handler.

On Sep 17, 2016 9:09 PM, "brg8" [email protected] wrote:

Having the same problem. Any update?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#13 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFX2qL0llKPqlOZYQk0hL1Mk7a6AkHAOks5qrKsjgaJpZM4Ij2vs
.

@jindrichbartek
Copy link

It's not bug. It's feature. Btw. explanation: #11 (comment)

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

3 participants