I am learning Meteor and I am wondering why my data is not reactive when I publish it as follows:
Meteor.publish("users", function (userId) {
// teams the user is member of
var teams = _.pluck(Teams.find({members:userId}).fetch(), '_id');
// users from all those teams
var userIds = _.union.apply(_,_.pluck(Teams.find({_id:{$in:teams}}).fetch(), 'members'));
// user cursor
return Meteor.users.find({_id:{$in:userIds}},{fields: {_id:1, profile: 1, emails:1}});
});
Obviously, this works though
Meteor.publish("users", function (userId) {
return Meteor.users.find();
});
I suppose the additional steps is responsible for breaking the reactivity, but how can I fix that?