Here is a modified leaderboard:
http://meteorpad.com/pad/CgEG3uYBZDceTERXA/Leaderboard
I added a limit to the players
cursor and display scorePlusOne
instead of score
.
Template.leaderboard.helpers({
players: function () {
return Players.find({}, { sort: { score: -1, name: 1 } , limit: Session.get('limit')});
Template.player.helpers({
scorePlusOne: function() {
console.log('scorePlusOne',this.name);
return this.score + 1;
When I increase the limit from 1 to 2, the first player template is not rerendered, but the scorePlusOne
helper is rerun.
I don't want any helpers of already-rendered templates to rerun unless they contain reactive data that changes. Is there any way to achieve this behavior?
Cache template helper results in
ReactiveVar
s and move the helper code to template autoruns:https://github.com/meteor/meteor/issues/4960#issuecomment-132715347