We’ll be extending the Simple Editor app from Chapter 2, using Local and Sync Storage. Then, I’ll introduce a mailing-list app to demonstrate what you can do with IndexedDB.
Many browsers, including Chrome, support
localStorage, which is similar to persistent cookies in that it stores KVPs. The main difference is that
localStorage has greater capacity and isn’t passed to the server along with HTTP requests. Similarly,
sessionStorage is similar to session cookies in that it lasts only as long as the current session.
However, Chrome Apps can’t use
localStorage. Instead, there’s a Chrome API,
localStorage is limited to strings) and, like most Chrome APIs, it operates asynchronously, allowing the app to be more responsive. What’s more, there’s a variant,
chrome.storage.sync, with the same API, which is automatically synchronized between computers running the same app, similar to the way that Sync Files are synchronized.
As is specified in Chapter 2, you need
storage permission in your manifest to use the
Chrome Apps can use
sessionStorage, but there’s no reason to do so. Because a Chrome App HTML page can’t be refreshed and can’t ...