【问题标题】:Is it possible to view all active subscriptions是否可以查看所有活动订阅
【发布时间】:2013-06-17 18:40:30
【问题描述】:

我通过各种自动运行设置了多个订阅。能够查看在任何给定时间处于活动状态的订阅对于调试目的很有用。这可能吗?

【问题讨论】:

    标签: meteor


    【解决方案1】:

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

    //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);
    

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

    【讨论】:

    • 感谢您的信息!
    【解决方案2】:

    对“有效”订阅一无所知。

    但是有一个对象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.
        });
    

    虽然不是你想要的。

    【讨论】:

    • Meteor.default_connection 未定义。知道为什么吗?
    猜你喜欢
    • 1970-01-01
    • 2019-11-26
    • 2016-12-29
    • 1970-01-01
    • 2019-07-25
    • 2017-01-06
    • 2012-01-25
    • 2016-09-30
    • 2022-01-27
    相关资源
    最近更新 更多