我有由各种自动运行设置的多个订阅。能够查看在任何给定时间处于活动状态的订阅对于调试目的很有用。这可能吗?
问问题
4877 次
2 回答
34
对“活动”订阅一无所知。
但是有一个对象 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.
});
不完全是你想要的。
于 2013-06-21T10:50:43.770 回答
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);
请注意,您可以看到“就绪”状态,以及订阅中使用的参数。
于 2016-09-11T10:55:50.363 回答