Hi. I am using React with Meteor 1.3 and the alt.js implementation of flux.
I am trying to figure out the best way of subscribing to publications. So far I have been doing it this way:
Tracker.autorun(() => {
const coachHandle = Meteor.subscribe('activities.show', id);
if (coachHandle.ready()) {
const activity = Activity.findOne({ _id: id });
this.fetchActivitySuccess(activity);
}
});
An action runs the above code when the component mounts.
The reason I’m doing this, is to have the action handle the subscribtion.
But the official meteor guide suggests using something like this (in the component):
export default createContainer(({params}) => {
console.log(params.activityId);
Meteor.subscribe('activities.show', params.activityId);
return {
activity: Activity.findOne({ _id: params.activityId })
};
}, ActivityShowContainer);
Is there any downside to my original way of doing things?