I am building a chat application and on my \"new chats\" page I have a list of contacts, which you can select one by one by tapping them (upon which I apply a CSS selected class
1) Define Tracker.Dependency
in the same place where you define your object:
var newChatters = [];
var newChattersDep = new Tracker.Dependency();
2) Use depend()
before you read from the object:
Template.newChatDetails.newChatters = function() {
newChattersDep.depend();
return newChatters;
};
3) Use changed()
after you write:
Template.contactsLayout.events({
'click #contactItem': function(e, t) {
...
newChatters.push(...);
newChattersDep.changed();
},
});