I am wondering: theoritically, if a helper runs whenever data changes, isn’t it more efficient to create observers? Eg:
Template['User.profile'].onCreated(function () {
this.user = new ReactiveVar(false);
this.observers = [];
const userObserver = Meteor.users.find({
_id: Router.current().params._id
}).observe({
added: (doc) => {
const profileObs = Profiles.find(doc.profile).observe({
added: (profile) => {
this.user.set(_.extend(this.user.get(), {
profile: profile
}));
},
changed: (profile) => {
this.user.set(_.extend(this.user.get(), {
profile: profile
}));
}
});
this.observers.push(profileObs);
}
});
this.observers.push(userObserver);
});
Template['User.profile'].onDestroyed(function () {
this.observers.forEach((obs) => obs.stop());
});
Wouldn’t this be faster and look more elegant?