當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Tracker.autorun方法代碼示例

本文整理匯總了TypeScript中meteor/tracker.Tracker.autorun方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Tracker.autorun方法的具體用法?TypeScript Tracker.autorun怎麽用?TypeScript Tracker.autorun使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在meteor/tracker.Tracker的用法示例。


在下文中一共展示了Tracker.autorun方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: constructor

 constructor() {
   Tracker.autorun(() => {
     this.isClient = MeteorMeteor.isClient;
     this.isCordova = MeteorMeteor.isCordova;
     this.isServer = MeteorMeteor.isServer;
     this.release = MeteorMeteor.release;
   });
   Tracker.autorun(() => {
     const ddpStatus = MeteorMeteor.status && MeteorMeteor.status();
     if(ddpStatus) {
       this.statusString = ddpStatus.status;
       switch (ddpStatus.status) {
         case 'connected':
           this.status = StatusEnum.connected;
           break;
         case 'connecting':
           this.status = StatusEnum.connecting;
           break;
         case 'failed':
           this.status = StatusEnum.failed;
           break;
         case 'waiting':
           this.status = StatusEnum.waiting;
           break;
         case 'offline':
           this.status = StatusEnum.offline;
           break;
         default:
           this.status = undefined;
           break;
       }
       this.connected = ddpStatus.connected;
       this.retryCount = ddpStatus.retryCount;
     } else {
       this.status = StatusEnum.offline;
       this.connected = false;
       this.retryCount = 0;
     }
   });
   Tracker.autorun(() => {
     this.userId = MeteorMeteor.userId && MeteorMeteor.userId();
     if (MeteorMeteor.user && MeteorMeteor.user()) {
       const user = MeteorMeteor.user();
       if (user.emails && user.emails.length > 0) {
         this.address = user.emails[0].address;
         this.verified = user.emails[0].verified;
       } else {
         this.address = undefined;
         this.verified = undefined;
       }
       this.username = user.username;
       this.createdAt = user.createdAt;
     } else {
       this.address = undefined;
       this.verified = undefined;
       this.username = undefined;
       this.createdAt = undefined;
     }
   });
 }
開發者ID:stphdenis,項目名稱:aurelia-meteor,代碼行數:60,代碼來源:meteor.ts

示例2:

		this.subscribe('conversationSubscriptions', ref, ()=>{
			Tracker.autorun(()=>{
				this.ngZone.run(()=>{
					this.userConversations = ConversationSubscriptions.find({'_id':ref}).fetch()[0].conversations;
				});
			});
		}, true);
開發者ID:gab3alm,項目名稱:lemonaidev3,代碼行數:7,代碼來源:conversations.component.ts

示例3: constructor

 constructor(zone: NgZone, params: RouteParams){
     Tracker.autorun(() => zone.run(() => {
         this.user = Meteor.users.findOne({
             '_id': params.get('id')
         });
     }));
 }
開發者ID:albertvazquezm,項目名稱:present,代碼行數:7,代碼來源:user-detail.ts

示例4: constructor

 constructor(zone: NgZone) {
   Tracker.autorun(() => zone.run(() => {
     this.presents = Presents.find({
       owner: Meteor.userId()
     }).fetch();
   }));
 }
開發者ID:albertvazquezm,項目名稱:present,代碼行數:7,代碼來源:present-list.ts

示例5: constructor

 constructor(params: RouteParams, zone: NgZone) {
   var productId = params.get('productId');
   this.product = Products.findOne(productId);
 	Tracker.autorun(() => zone.run(() => {
     this.cartList = Carts.find().fetch();
   }));
 }
開發者ID:ferrufino,項目名稱:VesperCart,代碼行數:7,代碼來源:product-detail.ts

示例6: constructor

	constructor(params: RouteParams, private _productService: ProductService, zone:NgZone){
		var categoryId = params.get('categoryId');
		this.category = Categories.findOne(categoryId);
		Tracker.autorun(() => zone.run(() => {
	  	this.products = Products.find().fetch();
		 this.cartList = Carts.find().fetch();
		}));
	}
開發者ID:ferrufino,項目名稱:VesperCart,代碼行數:8,代碼來源:display-category.ts

示例7:

 this.subscribe('ActiveEvents', ()=>{
   this.ActiveEvents = Events.find();
   // Once you fetch from a collectin it is no longer reactive
   // using tracker makes it reactive
   Tracker.autorun(()=>{
     this.empty = this.ActiveEvents.fetch()[0]; 
   });
 });
開發者ID:gab3alm,項目名稱:csun_nsls,代碼行數:8,代碼來源:login.component.ts

示例8:

			this.subscribe('conversationStream', this.conversationID, ()=>{
				Tracker.autorun(()=>{
					this.ngZone.run(()=>{
						this.messages = ConversationStreams.find({'_id':this.conversationID}).fetch()[0].messages;
						this.conversationTitle = ConversationStreams.find({'_id':this.conversationID}).fetch()[0].title;
					});
				});
			}, true);
開發者ID:gab3alm,項目名稱:lemonaidev3,代碼行數:8,代碼來源:dynamic-messages.component.ts

示例9: constructor

	constructor(params: RouteParams, ngZone: NgZone) {
		var courseID = params.get('courseID');

      	Tracker.autorun(() => {
          ngZone.run(() => {
          	this.course = Courses.findOne(courseID);
          });
        });
	}
開發者ID:Tianyu0312,項目名稱:tuxlab-app,代碼行數:9,代碼來源:gradedetails.ts

示例10:

        this.route.params.subscribe((params) => {
            this.plantId = params['plantId'];

            Tracker.autorun(() => {
                this.ngZone.run(() => {
                    this.plant = Plants.findOne(this.plantId)
                });
            });
        });
開發者ID:quantumleeps,項目名稱:meteor,代碼行數:9,代碼來源:view-plant-details.ts


注:本文中的meteor/tracker.Tracker.autorun方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。