本文整理汇总了TypeScript中meteor/tracker.Tracker类的典型用法代码示例。如果您正苦于以下问题:TypeScript Tracker类的具体用法?TypeScript Tracker怎么用?TypeScript Tracker使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tracker类的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;
}
});
}
示例2:
this.subscribe('conversationSubscriptions', ref, ()=>{
Tracker.autorun(()=>{
this.ngZone.run(()=>{
this.userConversations = ConversationSubscriptions.find({'_id':ref}).fetch()[0].conversations;
});
});
}, true);
示例3: constructor
constructor(zone: NgZone, params: RouteParams){
Tracker.autorun(() => zone.run(() => {
this.user = Meteor.users.findOne({
'_id': params.get('id')
});
}));
}
示例4: constructor
constructor(zone: NgZone) {
Tracker.autorun(() => zone.run(() => {
this.presents = Presents.find({
owner: Meteor.userId()
}).fetch();
}));
}
示例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();
}));
}
示例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();
}));
}
示例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];
});
});
示例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);
示例9: constructor
constructor(params: RouteParams, ngZone: NgZone) {
var courseID = params.get('courseID');
Tracker.autorun(() => {
ngZone.run(() => {
this.course = Courses.findOne(courseID);
});
});
}
示例10:
this.route.params.subscribe((params) => {
this.plantId = params['plantId'];
Tracker.autorun(() => {
this.ngZone.run(() => {
this.plant = Plants.findOne(this.plantId)
});
});
});