【问题标题】:Can I make all my subscriptions non-reactive in Meteor我可以让我的所有订阅在 Meteor 中都没有反应吗
【发布时间】:2015-08-10 03:05:13
【问题描述】:

是否可以让我的所有订阅都无反应?

这意味着,一旦初始集合被发送到客户端,服务器就会停止观察游标。

我在这里找到了以下答案:Are non-reactive Meteor db subscriptions possible?

这可行,但我更喜欢“全局”解决方案。

理想情况下,我希望可以选择哪些订阅是反应式的,哪些不是。例如,我希望所有登录的“管理员”用户都有反应数据,但是,普通网站访问者不需要这个。

谢谢! :)

【问题讨论】:

标签: meteor


【解决方案1】:

您只需在发布选项中添加 {reactive: false} 即可。

// This code only runs on the server
Meteor.publish("company", function companyPublication(){
  if (this.userId) {
    return Company.find({userId: this.userId},{limit:1, reactive: 
 false});
  } else {
    return this.ready();
  }
});

【讨论】:

    猜你喜欢
    • 2017-11-23
    • 1970-01-01
    • 2020-10-05
    • 1970-01-01
    • 2012-06-01
    • 1970-01-01
    • 2019-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多