-
Notifications
You must be signed in to change notification settings - Fork 52
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
How to handle multiple calls to same subscription? #163
Comments
You should always subscribe. No container should know of a app-global scope unless it is part of the The idea is: all the container needs to know is the context and what props it gets to render the component. |
@fermuch Are there any performance issues with subscribing twice to the exact same subscription? I'm wondering if I should just subscribe once in the parent of A and B, then pass the team down through props? Is it more performant than subscribing twice? But I always thought containers were supposed to remove the hassle of passing props down many levels of components that don't even use the props. |
No, there are none. The only problem would be doing something like |
If you want to read some more about Meteor's pub/sub, here is a great answer with lots of examples. |
I think your subscriptions will reset if you Route to a new page / view. so if you have multiple components (containers) on the same Route.. then you have no problem with multiple subs with the same values. But you should still think about how you best break down your components.. and make them as dumb as possible. but if you call a new route.. the subs get called again.. This is where some sort of subscription caching can help.. such as "meteorhacks:subs-manager" |
I have container A and B in my app.
In A, a subscription is called to get the team for the app. However, B also requires the same team. Containers A and B are mounted on the same page. Given that I'm not sure on which order they load in, should I subscribe again in B, or should I just retrieve the team in B assuming that A already subscribed?
What should Container B look like?
The text was updated successfully, but these errors were encountered: