I want to ask it is a good practice to send different type of collection using switch case in one subscription.
for example :
Meteor.publish('sub', (type) => {
if (type == "a") {return A.find();}
else {return B.find();}
});
I want to ask it is a good practice to send different type of collection using switch case in one subscription.
for example :
Meteor.publish('sub', (type) => {
if (type == "a") {return A.find();}
else {return B.find();}
});
In my opinion, it is not a good practice because you have tried to put every things in one function. How to handle your publication with a large number of requirement about validation/authorization/publish composite…
I see no technical problem doing this, if that is what you need. But you could have two publications, subA, subB, if you prefer, which would return all/none of the appropriate data for that type, depending on the type.
@taind because sometime there are many nearly identical collection with this i can save a few typing
thank you because i thought this would have some weird consequence on reactivity