// Works
var counter = 0;
var myInterval = Meteor.setInterval(function(){
counter++;
var time = moment().hour(0).minute(0).second(counter).format('HH:mm:ss');
console.log(time);
}, 1000);
// Inside Helper - Does Not Work
Template.clockRunner.helpers({
start: function () {
var counter = 0;
var time = moment().hour(0).minute(0).second(counter).format('HH:mm:ss');
var myInterval = Meteor.setInterval(function(){
counter++
}, 1000);
return time;
},
})
The first version console logs the time in increments of 1 second. The Helper version displays "00:00:00" in the DOM, but does not increment, if I console log the time in helper it logs "00:00:00" every second.
I'm not sure if I'm misunderstanding the reactive nature of helpers or if I'm not seeing a minor mistake. Thanks in advance!