当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Meteor.subscribe方法代码示例

本文整理汇总了TypeScript中meteor/meteor.Meteor.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Meteor.subscribe方法的具体用法?TypeScript Meteor.subscribe怎么用?TypeScript Meteor.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在meteor/meteor.Meteor的用法示例。


在下文中一共展示了Meteor.subscribe方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: ngOnInit

 ngOnInit() {
   Meteor.subscribe('posts', () => {
     this.posts = Posts.find({}, {
       sort: {
         dateTime: -1
       }
     });
   });
   Meteor.subscribe('timelines', () => {
     this.timelines = TimeLines.find({}, {
       sort: {
         dateTime: -1
       }
     });
   });
 }
开发者ID:RizkiMufrizal,项目名称:Socially-Angular2-Meteor,代码行数:16,代码来源:post-component.ts

示例2: onReady

 return this._promise((resolve, reject) => {
   const handle = Meteor.subscribe(name, ...args, {
     onReady() {
       resolve(handle);
     },
     onStop(error) {
       reject(error);
     }
   });
 });
开发者ID:jellyjs,项目名称:angular-meteor-promiser,代码行数:10,代码来源:angular-meteor-promiser.ts

示例3: composeFn

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 });
}
开发者ID:kucharskimaciej,项目名称:bullet-journal,代码行数:20,代码来源:compose.ts

示例4:

 return Observable.create(obs => {
     Meteor.subscribe('userData', () => {
         let user = Meteor.user();
         if(!user){
             this.router.navigate(['/login'])
         }else{
             obs.next(true);
             obs.complete();
         }
     });
 });
开发者ID:yk,项目名称:damgr,代码行数:11,代码来源:auth.guard.ts

示例5: if

 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();
                 }
             });
         });
     }
 });
开发者ID:yk,项目名称:kethlle,代码行数:19,代码来源:team.guard.ts

示例6:

Tracker.autorun(function () {
    Meteor.subscribe("chat-history", { room: Session.get("currentRoomId") });
});
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:3,代码来源:meteor-tests.ts

示例7: function

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);
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:30,代码来源:meteor-tests.ts

示例8: constructor

 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");
 }
开发者ID:euclid1990,项目名称:fruit,代码行数:6,代码来源:email.validator.ts


注:本文中的meteor/meteor.Meteor.subscribe方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。