browser.storage.local.set({
config1: {
“captchaUrl”: “://xxx.xxx.com/get_img”,
“content_script”: “site.js”
}
});
browser.storage.local.get().then(settings => {
let config2=settings[“config1”];
// block02, do something with config here
console.log(config2);
});
Is it guaranteed that the config2 would always get an object rather than undefined?? Or is there an order guarantee that the the storage.get() method above will get the data set by the storage.set() which is followed by storage.get() ?
I have made a test but I coundn’t find any documentation about this.
async means that StorageArea.set will not block, and the real storing action will work in the background, then the browser.storage.local.get() will be executed immediately, and the real retrieving action will also work in the background. After the real work in the background, both callbacks in then() method will get invoked.
Is the order between the real storing action and the real retrieving action also not guaranteed??