是否可以查看所有活动订阅

tom*_*ors 20 meteor

我有各种autoruns设置的多个订阅.调试目的是有用的,以便能够查看在任何给定时间哪些订阅处于活动状态.这可能吗?

soh*_*ifa 33

不了解"活跃"订阅.

但是有一个对象 Meteor.default_connection._subscriptions存储已经订阅直到给定时间的所有订阅的信息.

    var subs = Meteor.default_connection._subscriptions; //all the subscriptions that have been subscribed.

    Object.keys(subs).forEach(function(key) {
        console.log(subs[key]);   // see them in console.
    });
Run Code Online (Sandbox Code Playgroud)

不完全是你想要的.


Rob*_*obD 5

作为对上述内容的补充,我们可以以一种更容易检查多个订阅等的方式组织它们。

//all the subscriptions that have been subscribed.
var subs = Meteor.default_connection._subscriptions; 
var subSummary = {};

// organize them by name so that you can see multiple occurrences
Object.keys(subs).forEach(function(key) {
  var sub = subs[key];
  // you could filter out subs by the 'active' property if you need to
  if (subSummary[sub.name] && subSummary[sub.name].length>0) {
    subSummary[sub.name].push(sub);
  } else {
    subSummary[sub.name] = [sub];
  }
});
console.log(subSummary);
Run Code Online (Sandbox Code Playgroud)

请注意,您可以看到“就绪”状态以及订阅中使用的参数。