Hello,
I’m a beginner on Firefox adons and maybe i skipped some important steps…
i usually search on google for to find answers and solutions but this time i cant find my answer.
i have something like this:
on options page i set some storage variables
then on my background page on “storage change” i want to read storage variable…
is tired something like this:
background page:
var exclude = [];
var agents = [];
function onGot(item) {
agents = item[“agents”];
exclude = item[“exclude”];
}
function onError(error) {
console.log(‘Error: ${error}’);
}
browser.storage.onChanged.addListener(setUaString);
function setUaString() {
console.log(“xxxxxxxxxxxxxx”);
let gettingItem = browser.storage.sync.get([“agents”, “exclude”]);
gettingItem.then(onGot, onError);
}
i cant figure out why this is not working
my solution for now is to call another function on change :
function logStorageChange(changes, area){
agents = changes[‘agents’][‘newValue’];
exclude = changes[‘exclude’][‘newValue’];
}
but i’m afraid i will get into some issues later; for example if “agents” was not updated do i still get the value?
in my mind the ideea was simple: on any storage change read all parameters i need (not the changed ones)
thank you for you help