storage.js: Don't try and allow to register events for non-local backends

This commit is contained in:
Johannes Meyer 2019-07-30 08:17:29 +02:00
parent 62d4e73d5a
commit 5849c06314
1 changed files with 8 additions and 1 deletions

View File

@ -171,6 +171,10 @@
* @returns {void}
*/
onChange: function(key, callback, context) {
if (this.backend !== window.localStorage) {
throw new Error('[Storage] Only the localStorage emits events');
}
var prefixedKey = this.prefixKey(key);
if (typeof Icinga.Storage.subscribers[prefixedKey] === 'undefined') {
@ -273,7 +277,10 @@
this.storage = storage;
this.key = key;
storage.onChange(key, this.onChange, this);
if (storage.backend === window.localStorage) {
storage.onChange(key, this.onChange, this);
}
return this;
},