mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
storage.js: Allow to subscribe with multiple handlers to the same key
This commit is contained in:
parent
2bf050f57d
commit
9561057b81
@ -44,8 +44,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Icinga.Storage.subscribers[event.key] !== 'undefined') {
|
if (typeof Icinga.Storage.subscribers[event.key] !== 'undefined') {
|
||||||
var subscriber = Icinga.Storage.subscribers[event.key];
|
Icinga.Storage.subscribers[event.key].forEach(function (subscriber) {
|
||||||
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
|
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -122,7 +123,13 @@
|
|||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
onChange: function(key, callback, context) {
|
onChange: function(key, callback, context) {
|
||||||
Icinga.Storage.subscribers[this.prefixKey(key)] = [callback, context];
|
var prefixedKey = this.prefixKey(key);
|
||||||
|
|
||||||
|
if (typeof Icinga.Storage.subscribers[prefixedKey] === 'undefined') {
|
||||||
|
Icinga.Storage.subscribers[prefixedKey] = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
Icinga.Storage.subscribers[prefixedKey].push([callback, context]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user