Meteor:防止一个部分的实时更新/重新渲染

时间:2014-12-02 11:06:41

标签: meteor

在Meteor中,如何防止某些收集字段或页面的某些部分受到实时更新/重新渲染系统的影响?

我找到了一些答案,例如{{#constant}}和{{#isolate}},但现在它们已被折旧。

同样反应:假似乎也不适合我。

1 个答案:

答案 0 :(得分:0)

您可以尝试Tracker.nonreactive。这使您可以非反应性地访问它的反应数据源。例如:

<template name="tmplt">
  The counter is {{getCounter}}.
</template>
Template.tmplt.helpers({
  getCounter: function () {
    return Tracker.nonreactive(function () {
      return Session.get("counter");
    });
  }
});

更改&#34;计数器&#34;会话变量不会导致tmplt更新。

将数据库查询传递给#each时,请务必致电fetch

// Don't do this
return Tracker.nonreactive(function () {
  return Collection.find(...);
});

// Do this
return Tracker.nonreactive(function () {
  return Collection.find(...).fetch();
});
相关问题