Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 流星订阅钩?_Meteor - Fatal编程技术网

Meteor 流星订阅钩?

Meteor 流星订阅钩?,meteor,Meteor,我有一个非常愚蠢的问题,关于RouteControl上的订阅挂钩函数 我真的不知道.ready变量或方法来自何处,它是否与订阅的内置变量一起使用 PostsListController = RouteController.extend({ template: 'postsList', increment: 5, postsLimit: function() { return parseInt(this.params.postsLimit) || this.incremen

我有一个非常愚蠢的问题,关于RouteControl上的订阅挂钩函数

我真的不知道.ready变量或方法来自何处,它是否与订阅的内置变量一起使用

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是可变的?