Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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_Loader_Reactive - Fatal编程技术网

在Meteor反应表中显示加载程序,直到数据为客户端准备就绪

在Meteor反应表中显示加载程序,直到数据为客户端准备就绪,meteor,loader,reactive,Meteor,Loader,Reactive,我使用meteor反应表来显示数据列表。如何在设置代码中使用ready:ReactiveVar(布尔)选项?假设您的反应表显示了订阅中的数据。然后,您将使订阅的ready()状态通知反应表 Template.myTemplate.onCreated(function(){ this.mySub = Meteor.subscribe('mySubscription'); }); Template.myTemplate.helpers({ settings: function () {

我使用meteor反应表来显示数据列表。如何在设置代码中使用
ready:ReactiveVar(布尔)
选项?

假设您的反应表显示了订阅中的数据。然后,您将使订阅的
ready()
状态通知反应表

Template.myTemplate.onCreated(function(){
  this.mySub = Meteor.subscribe('mySubscription');
});

Template.myTemplate.helpers({
  settings: function () {
    return {
      collection: collection,
      rowsPerPage: 10,
      showFilter: true,
      fields: ['name', 'location', 'year'],
      ready: this.mySub.ready(),
    };
  }
});

请注意,这需要您在服务器上使用。

使用ReactiveVar我们可以获取订阅是否准备就绪

Template.myTemplate.onCreated(function(){
  this.isSubscriptionReady = new ReactiveVar(false);
});

Template.myTemplate.helpers({
  settings: function () {
    return {
      collection: collection,
      rowsPerPage: 10,
      showFilter: true,
      fields: ['name', 'location', 'year'],
      ready: Template.instance().isSubscriptionReady
    };
  },
  isSubscriptionReady: function () {
     return Template.instance().isSubscriptionReady.get();
  }
});

感谢您的回复,我已经使用reactiveVar解决了加载程序问题