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_Iron Router - Fatal编程技术网

Meteor 铁路由器流星自动退订?

Meteor 铁路由器流星自动退订?,meteor,iron-router,Meteor,Iron Router,当使用iron router更改为不同的模板(页面)时,是否会自动取消订阅不再需要的集合?下面的场景解释问题 在第1页,我们称之为Meteor.subscribe(文档,id) 铁路由器改到第2页 在第2页,我们称之为Meteor.subscribe(文档,id2),步骤1是否自动取消订阅 如果您在路由的waitOn功能中将句柄(或包含句柄的数组)返回到订阅,iron router将为您取消订阅。请参见此处: “铁路由器/流星”为您做到了这一点: 如果在反应式计算中调用Meteor.subsc

当使用iron router更改为不同的模板(页面)时,是否会自动取消订阅不再需要的集合?下面的场景解释问题

  • 在第1页,我们称之为Meteor.subscribe(文档,id)
  • 铁路由器改到第2页
  • 在第2页,我们称之为Meteor.subscribe(文档,id2),步骤1是否自动取消订阅
  • 如果您在路由的
    waitOn
    功能中将句柄(或包含句柄的数组)返回到订阅,iron router将为您取消订阅。

    请参见此处:

    “铁路由器/流星”为您做到了这一点: 如果在反应式计算中调用Meteor.subscribe,例如使用Deps.autorun,当计算无效或停止时,订阅将自动取消

    如果希望缓存部分订阅,请参阅此优秀软件包:


    是的,Meteor会自动取消订阅在反应式计算中运行的订阅(这通常是
    iron:router
    中的情况),因此,meteorhacks创建了类似subscription manager的东西,可以在需要时防止这种行为。
    this.route('postPage', {
        path: '/post/:_id',
        template: 'postPage',
        waitOn: function() {
          return Meteor.subscribe('post', this.params._id);
        },
        cache: 5, //cache 5 blog posts
        expire: 3 //expire them if inactive for 3 minutes
      });