mirror of
https://github.com/zotero/zotero.git
synced 2026-10-10 03:28:10 +00:00
Log the actual number of Notifier observers for a type
This commit is contained in:
parent
4c5920ba9a
commit
15252623d7
1 changed files with 27 additions and 5 deletions
|
|
@ -119,11 +119,20 @@ Zotero.Notifier = new function(){
|
|||
|
||||
var queue = _inTransaction && !force;
|
||||
|
||||
Zotero.debug("Notifier.trigger('" + event + "', '" + type + "', " + '[' + ids.join() + '], ' + extraData + ')'
|
||||
+ (queue ? " queued" : " called " + "[observers: " + Object.keys(_observers).length + "]"));
|
||||
if (extraData) {
|
||||
Zotero.debug("Extra data:");
|
||||
Zotero.debug(extraData);
|
||||
if (Zotero.Debug.enabled) {
|
||||
Zotero.debug("Notifier.trigger("
|
||||
+ "'" + event + "', "
|
||||
+ "'" + type + "', "
|
||||
+ "[" + ids.join() + "]"
|
||||
+ (extraData ? ", " + extraData : "")
|
||||
+ ")"
|
||||
+ (queue
|
||||
? " queued"
|
||||
: " called " + "[observers: " + _countObserversForType(type) + "]")
|
||||
);
|
||||
if (extraData) {
|
||||
Zotero.debug(extraData);
|
||||
}
|
||||
}
|
||||
|
||||
// Merge with existing queue
|
||||
|
|
@ -215,6 +224,19 @@ Zotero.Notifier = new function(){
|
|||
}
|
||||
|
||||
|
||||
function _countObserversForType(type) {
|
||||
var num = 0;
|
||||
for (let i in _observers) {
|
||||
// Skip observers that don't handle notifications for this type (or all types)
|
||||
if (_observers[i].types && _observers[i].types.indexOf(type) == -1) {
|
||||
continue;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
|
||||
this.untrigger = function (event, type, ids) {
|
||||
if (!_inTransaction) {
|
||||
throw ("Zotero.Notifier.untrigger() called with no active event queue")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue