mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-25 06:44:33 +02:00
storage.js: Don't use .bind() to define a callbacks context
This commit is contained in:
parent
03fc052749
commit
8377a2d096
@ -96,11 +96,12 @@
|
|||||||
*
|
*
|
||||||
* @param {string} key
|
* @param {string} key
|
||||||
* @param {function} callback
|
* @param {function} callback
|
||||||
|
* @param {object} context
|
||||||
*
|
*
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
subscribe: function(key, callback) {
|
subscribe: function(key, callback, context) {
|
||||||
this.subscribers[this.prefixKey(key)] = callback;
|
this.subscribers[this.prefixKey(key)] = [callback, context];
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +111,8 @@
|
|||||||
*/
|
*/
|
||||||
onStorage: function(event) {
|
onStorage: function(event) {
|
||||||
if (typeof this.subscribers[event.key] !== 'undefined') {
|
if (typeof this.subscribers[event.key] !== 'undefined') {
|
||||||
this.subscribers[event.key](JSON.parse(event.oldValue), JSON.parse(event.newValue));
|
var subscriber = this.subscribers[event.key];
|
||||||
|
subscriber[0].call(subscriber[1], JSON.parse(event.newValue), JSON.parse(event.oldValue), event);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -198,7 +200,7 @@
|
|||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|
||||||
storage.subscribe(key, this.onChange.bind(this));
|
storage.subscribe(key, this.onChange, this);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -214,10 +216,9 @@
|
|||||||
/**
|
/**
|
||||||
* Update the set
|
* Update the set
|
||||||
*
|
*
|
||||||
* @param {Array} oldValue
|
|
||||||
* @param {Array} newValue
|
* @param {Array} newValue
|
||||||
*/
|
*/
|
||||||
onChange: function(oldValue, newValue) {
|
onChange: function(newValue) {
|
||||||
// Check for deletions first
|
// Check for deletions first
|
||||||
this.values().forEach(function (value) {
|
this.values().forEach(function (value) {
|
||||||
if (newValue.indexOf(value) < 0) {
|
if (newValue.indexOf(value) < 0) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user