A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

IndexedDB change observers

dknox
2016-05-19

IndexedDB doesn’t have any observer support. This could normally be implemented by the needed website (or third party) as a wrapper around the database. However, IDB spans browsing contexts (tabs, workers, etc), and implementing a javascript wrapper that supports all of the needed features would be very difficult and performance optimization of the features would be impossible.

Use cases for observers include:

  • Updating the UI from database changes (data binding).
  • Syncing local state from background worker (like a ServiceWorker) or another tab making changes.
  • Serializing changes for network communication.
  • Simplified application logic.
plehegar
2016-05-19

Did you look at https://github.com/dmurph/indexed-db-observers/blob/gh-pages/EXPLAINER.md ?

dmurph
2016-05-20

Thanks Dru & Philippe!

Any feedback on our spec at

would be helpful.

I also plan on updating updating the creation sematics to be more like IntersectionObserver here: https://github.com/dmurph/indexed-db-observers/issues/24 and I’d love any feedback about that. (Note: that issue has some good examples usages as well)

btseng
2016-05-31

I like this idea to add observer support to current IndexedDB design for web developer to provide better experience and consistent data to the user when multiple tabs are open. The only concern/limitation so far to me is addressed in https://github.com/dmurph/indexed-db-observers/issues/24#issuecomment-222052352 The transaction ordering has been confirmed to be restricted even if it’s an empty transaction. I’d still like to see if we can improve it instead of restricting it.

Thanks for your efforts to improve the use cases of the IndexedDB! :slight_smile:

cwilso
2016-06-01

Sounds great. @dmurph, can you move the repo to WICG?

dmurph
2016-06-03

Done!