From 9e89eb521a9db385c496131dbfdfbe9cf4eeb308 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 9 Jan 2020 20:09:32 -0500 Subject: [PATCH] Added config callback support. --- SB.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/SB.js b/SB.js index eb6c489f..6a74077f 100644 --- a/SB.js +++ b/SB.js @@ -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 = {