Skip to content

Commit

Permalink
Made a simple publication/subscription for comments.
Browse files Browse the repository at this point in the history
chapter10-4
  • Loading branch information
tmeasday committed Oct 19, 2015
1 parent 1f82c0a commit 944cb07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion lib/router.js
Expand Up @@ -3,14 +3,17 @@ Router.configure({
loadingTemplate: 'loading', loadingTemplate: 'loading',
notFoundTemplate: 'notFound', notFoundTemplate: 'notFound',
waitOn: function() { waitOn: function() {
return [Meteor.subscribe('posts'), Meteor.subscribe('comments')]; return Meteor.subscribe('posts');
} }
}); });


Router.route('/', {name: 'postsList'}); Router.route('/', {name: 'postsList'});


Router.route('/posts/:_id', { Router.route('/posts/:_id', {
name: 'postPage', name: 'postPage',
waitOn: function() {
return Meteor.subscribe('comments', this.params._id);
},
data: function() { return Posts.findOne(this.params._id); } data: function() { return Posts.findOne(this.params._id); }
}); });


Expand Down
7 changes: 4 additions & 3 deletions server/publications.js
Expand Up @@ -2,6 +2,7 @@ Meteor.publish('posts', function() {
return Posts.find(); return Posts.find();
}); });


Meteor.publish('comments', function() { Meteor.publish('comments', function(postId) {
return Comments.find(); check(postId, String);
}) return Comments.find({postId: postId});
});

0 comments on commit 944cb07

Please sign in to comment.