本文整理匯總了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)
});
});
});