storage.js: Pass the value to event subscribers of StorageAwareMap

This commit is contained in:
Johannes Meyer 2019-07-10 07:52:21 +02:00
parent 8937e11a09
commit 383895fd92
1 changed files with 4 additions and 3 deletions

View File

@ -256,8 +256,8 @@
// Check for deletions first. Uses keys() to iterate over a copy // Check for deletions first. Uses keys() to iterate over a copy
this.keys().forEach(function (key) { this.keys().forEach(function (key) {
if (newValue === null || typeof newValue[key] === 'undefined') { if (newValue === null || typeof newValue[key] === 'undefined') {
$(window).trigger('StorageAwareMapDelete', [key, this.data.get(key)['value']]);
this.data.delete(key); this.data.delete(key);
$(window).trigger('StorageAwareMapDelete', key);
} }
}, this); }, this);
@ -272,7 +272,7 @@
this.data.set(key, newValue[key]); this.data.set(key, newValue[key]);
if (! known) { if (! known) {
$(window).trigger('StorageAwareMapAdd', key); $(window).trigger('StorageAwareMapAdd', [key, newValue[key]['value']]);
} }
}, this); }, this);
}, },
@ -280,7 +280,8 @@
/** /**
* Register an event handler to handle storage updates * Register an event handler to handle storage updates
* *
* Available events are: add, delete * Available events are: add, delete. The handler receives the
* key and its value as second and third argument, respectively.
* *
* @param {string} event * @param {string} event
* @param {object} data * @param {object} data