Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting events on IndexedDB updates from another tab

If I have IndexedDB database opened in multiple tabs, can I track data changes on all tabs without reloading?

like image 607
Troll the Legacy Avatar asked Oct 29 '25 07:10

Troll the Legacy


1 Answers

There's no built in way to do this with IndexedDB alone. You basically have two options:

  1. Poll IndexedDB with some frequency and check for new values

  2. Use some other way of cross-tab communication to send a signal that you need to check for new values from IndexedDB. For example localStorage (emits cross-tab events when something changes) or a BroadcastChannel (designed exactly for the purpose of cross-tab communication, but does not have perfect cross browser support).

like image 51
dumbmatter Avatar answered Oct 31 '25 08:10

dumbmatter