Hi,
Can someone explain the two comments in this example from the blaze guide
I’m having a hard time preventing re-rendering, namely just passing {{> nestedTpl id=this._id}}
leads to a full re-render if this changes (although this._id i the same). so i was hoping i’m missing some trick in this post :S
Template.Lists_show_page.helpers({
listArgs(listId) {
const instance = Template.instance();
return {
todosReady: instance.subscriptionsReady(),
// We pass `list` (which contains the full list, with all fields, as a function
// because we want to control reactivity. When you check a todo item, the
// `list.incompleteCount` changes. If we didn't do this the entire list would
// re-render whenever you checked an item. By isolating the reactiviy on the list
// to the area that cares about it, we stop it from happening.
list() {
return Lists.findOne(listId);
},
// By finding the list with only the `_id` field set, we don't create a dependency on the
// `list.incompleteCount`, and avoid re-rendering the todos when it changes
todos: Lists.findOne(listId, {fields: {_id: true}}).todos()
};
}
});
Thanks,