title: How to periodically update a variable using meteor
body: <p>I have a session variable that I want to update with a fixed periodicity. Say, I want this variable to be increased by 1 every 60 seconds. </p>
  
  <p>It seems to me that the best place for doing this is inside the helpers section of the relevant template. I first tried to do this using setInterval as described <a href="http://www.w3schools.com/js/js_timing.asp">here</a>, but that didn't work (the function just didn't seem to repeat). </p>
  
  <p>I then tried what I thought would be a straightforward solution, but this also doesn't work. See below. The helper variable 'currentPosition' is supposed to return the current minute of the day (plus an offset). However, it only does this when the template is first called and when the session variable 'offset' is changed in a function that's defined in the 'events' section, which responds to a click on a particular div (a 'next' button).</p>
  
  <pre><code>    currentPosition: function () {
          var d = new Date();
          var h = d.getHours();
          var m = d.getMinutes();
          var w = h * 60 + m;
  
          Session.set("position", w + Session.get("offset"));
  
          return Session.get("position");
      },
  </code></pre>
  
  <p>I would think that the above helper would actively update the value for 'currentPosition' every minute. Yet it does not.</p>
  
  <p>So, my question is, how can I have a session variable change every, say, 60 seconds, increasing it by, say, 1, while the new value of the session variable is reflected within the app, when the variable is adjusted.</p>
  
  <p>(If there's a straightforward and completely different solution which works in meteor, I'm not aware of it, so do point it out to me if I'm missing something obvious.)</p>