Procházet zdrojové kódy

Commit 11.2: Add publish and subscribe.

Frederic G. MARAND před 8 roky
rodič
revize
4df3e171de
1 změnil soubory, kde provedl 9 přidání a 0 odebrání
  1. 9 0
      simple-todos.js

+ 9 - 0
simple-todos.js

@@ -1,7 +1,16 @@
 Tasks = new Mongo.Collection("tasks");
 
+if (Meteor.isServer) {
+  Meteor.publish('tasks', function () {
+    var ret = Tasks.find();
+    return ret;
+  })
+}
+
 if (Meteor.isClient) {
   // This code only runs on the client
+  Meteor.subscribe('tasks');
+
   Template.body.helpers({
     tasks: function () {
       if (Session.get('hideCompleted')) {