When you want the tele of information are changed after some event or some operation you can use the Deps.Dependency.
You should put in your javascript file:
var myDependencyVar = new Deps.Dependency ;
You should place in the event that will hold the responsible operation for later update other data:
myDependencyVar.changed ();
You must place in the helpers you want to be triggered again:
myDependencyVar.depend ();
Example:
I want whenever change the value selected in a input the buildNewValues function is called and the new values will render on the page.
var newValueDep = new Deps.Dependency ;
Template.MyTemplate.events({
"change .mySelect" : function(e) {
e.preventDefault();
buildNewValues();
newValueDep.changed();
},
Template.MyTemplate.helpers({
'getAllValues': function(){
newValueDep.depend()
{...}
},
This is a interesting tip to go approaching the concepts of reactivity. The only thing that would change would be to use Tacker instead of Devs, thus:
var newValueDep = new Tracker.Dependency();
https://github.com/meteor/meteor/wiki/Tracker-Manual
Regards.
LikeLiked by 1 person