Hi,
I’m trying to follow “best practices” for React/FlowRouter and handle my subscriptions in my components:
For example:
<List>
<Post postId="idstring" />
<Post postId="idstring" />
...
</List>
Then in my getMeteorData()
function I subscribe to the post:
getMeteorData() {
var handle = Meteor.subscribe('postById', this.props.id);
if(handle.ready()) {
return {
post: Posts.findOne({_id: this.props.id}),
}
}
}
This seems the most correct way to do this, because all the handling is contained within the component, and it can be used everywhere without needing any external data. But it is slow when rendering large lists (1000 items) because this results in 1000 subscriptions.
A faster way would be to subscribe to all posts in <List>
and pass the post object to each <Post>
but this does not seem the cleanest way to do this.
What would be the correct way of doing something like this? I’m moving to fetching the data in <List>
and using meteorhacks:subs-manager
for now, but it doesn’t feel 100% right.