Simple Clock In Meteor.js Or How To Reload Templates?
I'm trying with Templates in meteor.js, but how can I reload them after a given time? For example I want to have a Template called 'time' which has to reload every second to show t
Solution 1:
The simplest way to reload a template is to provide and change a reactive data source. In your case, this could be the clock value.
var clock = new ReactiveVar(new Date());
Template.time.onCreated(function() {
Meteor.setInterval(function() {
clock.set(new Date());
}, 1000);
});
Template.time.helpers({
clock: function() {
var currentTime = clock.get();
...
},
});
Post a Comment for "Simple Clock In Meteor.js Or How To Reload Templates?"