Meteor 流星订阅钩?
我有一个非常愚蠢的问题,关于RouteControl上的订阅挂钩函数 我真的不知道.ready变量或方法来自何处,它是否与订阅的内置变量一起使用Meteor 流星订阅钩?,meteor,Meteor,我有一个非常愚蠢的问题,关于RouteControl上的订阅挂钩函数 我真的不知道.ready变量或方法来自何处,它是否与订阅的内置变量一起使用 PostsListController = RouteController.extend({ template: 'postsList', increment: 5, postsLimit: function() { return parseInt(this.params.postsLimit) || this.incremen
PostsListController = RouteController.extend({
template: 'postsList',
increment: 5,
postsLimit: function() {
return parseInt(this.params.postsLimit) || this.increment;
},
findOptions: function() {
return {sort: {submitted: -1}, limit: this.postsLimit()};
},
subscriptions: function() {
this.postsSub = Meteor.subscribe('posts', this.findOptions());
},
posts: function() {
return Posts.find({}, this.findOptions());
},
data: function() {
var hasMore = this.posts().count() === this.postsLimit();
var nextPath = this.route.path({postsLimit: this.postsLimit() + this.increment});
return {
posts: this.posts(),
ready: this.postsSub.ready,
nextPath: hasMore ? nextPath : null
};
}
});
您的
this.ready()
变量派生自路由器放入等待队列this.wait(…)
的任何内容。订阅将订阅添加到等待队列中,但不会像waitOn:
hook那样自动使用加载模板。-ready
实际上是订阅句柄的一种方法(Meteor.subscribe返回的对象)。我认为this.postsub.ready是可变的?