Last active
August 29, 2015 14:23
-
-
Save czbaker/f46b4ba1773c4a9be24c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Template.layout.onCreated(function() { | |
| var follows = Follows.find({owner: this.userId}, { fields: { uid: 1 }}).map(function(doc) { | |
| return doc._id; | |
| }); | |
| console.log(follows); | |
| Events.find( { uid: { $in: follows } }).observe({ | |
| added: function(doc) { | |
| sAlert.success("New event created!") | |
| } | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Base configuration | |
| Router.configure({ | |
| layoutTemplate: 'layout', | |
| loadingTemplate: 'spin', | |
| waitOn: function() { | |
| return [ | |
| Subs.subscribe('categories'), | |
| Subs.subscribe('userFollows'), | |
| Subs.subscribe('followedActivity') | |
| ]; | |
| } | |
| }); | |
| // Publications | |
| Meteor.publish('userFollows', function() { | |
| return Follows.find({owner: this.userId}); | |
| }); | |
| Meteor.publish('followedActivity', function() { | |
| if (this.userId) { | |
| // Get the user's follows, then pluck the IDs only. | |
| var follows = Follows.find({owner: this.userId}, { fields: { uid: 1 }}).map(function(doc) { | |
| return doc._id; | |
| }); | |
| return Events.find( { uid: { $in: follows } } ); | |
| } else { | |
| this.ready(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment