Browse Source

Use Meteor.setInterval() to update a session variable with a reactive display.

Frederic G. MARAND 8 years ago
parent
commit
0f5d189667
1 changed files with 10 additions and 6 deletions
  1. 10 6
      textcircle.js

+ 10 - 6
textcircle.js

@@ -2,6 +2,16 @@
 this.Documents = new Mongo.Collection("documents");
 
 if (Meteor.isClient) {
+  Meteor.setInterval(function () {
+    Session.set("current_date", new Date());
+  }, 1000);
+
+  Template.date_display.helpers({
+    current_date: function () {
+      return Session.get("current_date");
+    }
+  });
+
   Template.editor.helpers({
     docid: function () {
       let doc = Documents.findOne();
@@ -9,12 +19,6 @@ if (Meteor.isClient) {
     }
   });
 
-  Template.date_display.helpers({
-    current_date: function () {
-      return new Date();
-    }
-
-  });
 }
 
 if (Meteor.isServer) {