ListingForm = React.createClass({
mixins: [ReactMeteorData],
getMeteorData() {
var data = {};
var categoriesHandle = Meteor.subscribe('categories.all');
var citiesHandle = Meteor.subscribe('cities.all');
if (categoriesHandle.ready() && citiesHandle.ready()) { // YUCK
data.categories = Categories.find().fetch();
data.cities = Cities.find().fetch();
}
return data;
}
});
I’m subscribing to two collections in my component (they populate two different select elements) and the code for the handle ready checks looks bad. What if I subscribe to five different collections in one component down the line, would I need to do?
Im actually going to implement something like this. Much like template.subscribe giving you Template.subscriptionsReady Essentially look at that code and it can guide you to a solution
I can see a large form with multiple select elements populated by multiple mongo collections, not really something crazy or a hypothetical, just based on previous business needs I had.
A large form with multiple select elements seems like it would be best split into a component for each select. Then you only need one subscription per component.