mantrajs / mantra-sample-blog-app

A sample blog app built with Mantra
http://mantra-sample-blog-app.herokuapp.com/
MIT License
296 stars 104 forks source link

Subscriptions inside composer #47

Closed aykutyaman closed 8 years ago

aykutyaman commented 8 years ago

What is the best way to do multiple subscriptions inside to the composer function. I do in this way up until now:

export const composer = ({context, companyId}, onData) => {
  const {Meteor, Collections} = context();
  const handle1 = Meteor.subscribe('vehicles.list', companyId);
  const handle2 = Meteor.subscribe('companies.single', companyId);
  if (handle1.ready() && handle2.ready()) {
    const vehicles = Collections.Vehicles.find().fetch();
    const company = Collections.Companies.findOne();
    onData(null, {vehicles, company});
  }
};

Or do I have to do something like multiple composers for subscriptions. multiple composers

arunoda commented 8 years ago

I think you've the correct way to handle it. Using multiple composer for this purpose is not a good idea. Use multiple composers when dealing with multiple data sources.

aykutyaman commented 8 years ago

Thank you