Polymer / pwa-starter-kit-hn

https://pwa-starter-kit-hn.appspot.com/
69 stars 18 forks source link

Request: Add documentation for IndexedDB #34

Closed Anid4u2c closed 5 years ago

Anid4u2c commented 5 years ago

As per the PWA Starter Kit this sample app implements a "pattern for using indexedDB for local storage", yet the README file makes no mention of it.

Ultimately, I'm attempting to implement IndexedDb in my own apps, and would like a reference to it's implementation in this application sample, using Polymer 3.

Thanks!

keanulee commented 5 years ago

We don't have specific documentation about IndexedDB, but all of the related code is part of the favorites action creators (https://github.com/Polymer/pwa-starter-kit-hn/blob/master/src/actions/favorites.ts) since favorites are the only thing the app stores in IndexedDB. Basically these are all async redux-thunk actions that dispatch after database request success. The loadFavorites() action is dispatched only when the app initially loads to populate the store with IndexedDB data (https://github.com/Polymer/pwa-starter-kit-hn/blob/8aec8286000b8729d3bdea7a6dbb8c8adf6ebb1e/src/components/hn-summary.ts).

Anid4u2c commented 5 years ago

Thanks @keanulee! Your comment provides all the info I need, basically a reference to the code where IndexedDB was called, and it helps to know when loadFavorites() is called. From all that I can tell that dbPromise is used to add, remove, or save a favorite.