Added config callback support.

This commit is contained in:
Ajay Ramachandran
2020-01-09 20:09:32 -05:00
parent 4301a6bfe3
commit 9e89eb521a

15
SB.js
View File

@@ -1,4 +1,11 @@
SB = {};
SB = {
/**
* Callback function when an option is updated
*
* @type {CallableFunction}
*/
configListeners = []
};
// Function setup
@@ -82,9 +89,13 @@ function decodeStoredItem(data) {
function configProxy() {
chrome.storage.onChanged.addListener((changes, namespace) => {
for (key in changes) {
for (const key in changes) {
SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
}
for (const callback of SB.configListeners) {
callback(changes);
}
});
var handler = {