ngOnInit() {
   Meteor.subscribe('posts', () => {
     this.posts = Posts.find({}, {
       sort: {
         dateTime: -1
       }
     });
   });
   Meteor.subscribe('timelines', () => {
     this.timelines = TimeLines.find({}, {
       sort: {
         dateTime: -1
       }
     });
   });
 }
 return this._promise((resolve, reject) => {
   const handle = Meteor.subscribe(name, ...args, {
     onReady() {
       resolve(handle);
     },
     onStop(error) {
       reject(error);
     }
   });
 });
function composeFn(_, onData) {
    const subs = [
        Meteor.subscribe('users.me'),
        Meteor.subscribe('posts.recent')
    ];


    if (subs.some((sub) => !sub.ready())) {
        return;
    }

    const user = Meteor.users.findOne(Meteor.userId());
    const posts = Posts.find({ author: Meteor.userId() }, {
        sort: {
            created_at: -1
        }
    }).fetch();

    onData(null, { posts, user, isLoggedIn: !!user });
}
Example #4
0
 return Observable.create(obs => {
     Meteor.subscribe('userData', () => {
         let user = Meteor.user();
         if(!user){
             this.router.navigate(['/login'])
         }else{
             obs.next(true);
             obs.complete();
         }
     });
 });
Example #5
0
 Tracker.autorun(() => {
     let user = Meteor.user();
     if(user){
         Meteor.subscribe('teams', task._id, () => {
             let team = Teams.findOne({taskId: task._id, members: user._id});
             let guardingTeams = route.url.length == 3 && route.url[route.url.length-1].path == 'teams';
             this.ngZone.run(() => {
                 if(!team && !guardingTeams){
                     this.router.navigate(['/tasks', task._id, 'teams'])
                 }else if(team && guardingTeams){
                     this.router.navigate(['/tasks', task._id])
                 }else{
                     obs.next(true);
                     obs.complete();
                 }
             });
         });
     }
 });
Example #6
0
Tracker.autorun(function () {
    Meteor.subscribe("chat-history", { room: Session.get("currentRoomId") });
});
Example #7
0
Tracker.autorun(function () {
    Meteor.subscribe("chat", { room: Session.get("current-room") });
    Meteor.subscribe("privateMessages");
});
Example #8
0
Tracker.autorun(function () {
    Meteor.subscribe("counts-by-room", Session.get("roomId"));
});
Example #9
0
Tracker.autorun(function () {
    Meteor.subscribe("counts-by-room", Session.get("roomId"));
});

// Checking status
let status: DDP.Status = 'connected';

console.log("Current room has " +
    Counts.find(Session.get("roomId")).count +
    " messages.");

/**
 * From Publish and Subscribe, Meteor.subscribe section
 */
Meteor.subscribe("allplayers");

/**
 * Also from Meteor.subscribe section
 */
Tracker.autorun(function () {
    Meteor.subscribe("chat", { room: Session.get("current-room") });
    Meteor.subscribe("privateMessages");
});

/**
 * From Methods, Meteor.methods section
 */
Meteor.methods({
    foo: function (arg1: string, arg2: number[]) {
        check(arg1, String);
Example #10
0
 constructor() {
     // Email has already been taken
     // By default, Meteor only publishes the logged in user and you can, as you mention, run queries against that user.
     // In order to access the other users you have to publish them on the server:
     Meteor.subscribe("users.all");
 }