On 9/20/2012 3:08 PM, Matt Kruse wrote:
> Since storage operations are async, you often need to get multiple
> options at the same time, and you don't want to fire them as separate
> requests. It's easier to retrieve and store your whole preference
> structure as one JSON object. Using the chrome.storage.* API, you don't
> even have to parse/stringify the JSON, you can just store it directly.
>
> The only issue I have right now is that each tab reads in its own JSON
> object from preferences, and stores it. So if another tab changes an
> option, the first tab doesn't see that change. So right now, whenever I
> update a value, I first retrieve my JSON, then update it. It's an extra
> step but doesn't seem to impact performance.
It's possible to request a list of keys from chrome.storage by passing
an array of them, which avoids the multiple-requests issue without
introducing the problems using a single JSON object can cause.