Template keeps repeating

I have a variable as such:

randomVariable= 0;
var randomVariableDep= new Tracker.Dependency;

and it’s set and get functions are the following:

setRandomVariable= function (newValue) { randomVariable= newValue; randomVariableDep.changed(); };

getRandomVariable= function(){
return randomVariable;

I have a template, as such:

Template.random.helpers({ someFunctioin: function() { return getRandomVariable(); } });

and in my HTML file, I have:

<template name="random"> {{someFunction}} </template>

and I use it within the HTML file as such: {{> random}}

The template helper keeps on repeating over and over again and makes the application lag and makes it unusable. How can I fix this?

Can you show all of your code for the random Template, including where you call setRandomVariable? Since you’re calling changed in setRandomVariable, that’s where you’re triggering the invalidation of any dependent computations, so that’s where I’d recommend troubleshooting first. Also - your code above has typos in it (someFunction and someFunctioin), so it would be helpful to see something a little closer to your real code (so we can make sure we’re helping you pinpoint the real problem).

Hey Hwillson,

I actually figured it out. It was just a minor error in my code. I got it to work now! Thanks for your help.