【问题标题】:Reactive Method call in meteor is not Reactive流星中的反应性方法调用不是反应性的
【发布时间】:2017-12-24 15:28:28
【问题描述】:

我们在meteor的帮助器中使用ReactiveMethod调用。但是大多数时候没有刷新浏览器它会显示以前的数据(如果传递的参数没有改变)。解决办法是什么?

我使用下面方法的内部助手

customerOutsTanding: function(){ 
return ReactiveMethod.call("outstanding",customerId); 
} 

outstanding 将使用 boostrap 模型输入文本支付,它会关闭。但是使用响应式方法调用它不会更新。刷新浏览器后它会得到更新

【问题讨论】:

  • 如果不显示任何实现代码,对您帮助不大。
  • 内部助手我使用下面的方法 customerOutsTanding: function(){ return ReactiveMethod.call("outstanding",customerId);使用boostrap模型输入文本支付未完成,它会关闭。但使用反应方法调用它不会更新。刷新浏览器后它会更新

标签: meteor meteor-blaze


【解决方案1】:

ReactiveMethod.call 仅在参数更改时再次调用。在您的情况下,参数 iscustomerId 不会更改,因为它不是反应式数据源。

您可能需要使用Tracker.Dependency (https://docs.meteor.com/api/tracker.html#tracker_dependency) 再次被动触发此功能。像这样的

var outstandingDep = new Tracker.Dependency;

customerOutsTanding: function(){ 
  outstandingDep.depend();
  return ReactiveMethod.call("outstanding",customerId); 
} 

然后,当您想更改从问题中不清楚的依赖项时,您需要调用outstandingDep.changed() 可能是您需要在输入文本更改时调用。

【讨论】:

    猜你喜欢
    • 2015-09-13
    • 1970-01-01
    • 2019-03-22
    • 2016-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-08
    相关资源
    最近更新 更多