I need a way to avoid useless calculations; In reactive functions, I have a reactive object, I just need one property, but if any of this object changes, the whole function is recalculated:
Template.registerHelper('name', function() {
console.log("running");
return Meteor.user().profile.name;
});
(In html
<body><p>My name: {{name}}</p></body>
)
Now change your age:
Meteor.users.update({_id:Meteor.userId()},{$set:{"profile.age":20}});
You guess what you see on your console (second time ...)
running x2
but it should only be started once, because the name has not changed
Why is it important? In my application, I have complex calculations, and the user status of online / inaction easily changes.
source
share