當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。