OK, so, if I have an object activeMenus
: (or an array of objects, as is the case with the custom menus)
{
"enablebbCode": true,
"enableHTML": true,
"enableVbulletin": true,
"enableXHTML": true,
"enableMarkDown": true,
"enableCustom": true,
"enableSymbol": false
}
The way that I have am currently saving it, retreiving it, and listening using the window.localStorage API is:
localStorage.setItem('activeMenus',JSON.stringify(activeMenus));
JSON.parse(localStorage.getItem('activeMenus'));
window.addEventListener("storage", generateMenu, false);
This has the disadvantages of being wiped if the user clears data, and also it requires variables to be stringified and parsed on storage and retrieval.
Using the browser.storage.local API, this would look like:
browser.storage.local.set(activeMenus)
browser.storage.local.get(activeMenus)
window.addEventListener(“storage”, generateMenu, false);
browser.addEventListener(“storage”, generateMenu, false);
And then the data would not be purged when the user clears their personal data, and as a bonus, I would not have to stringify and parse.
Am I correct in my reading of this?