Receive notification when an indexed log entry changes in another tab

If a user opens several instances of a web application on several tabs, any instance can be notified of changes localStoragemade by any other instance by registering an event listener storage. Then the tab receiving this notification may respond and, for example, update the user interface in accordance with the changes.

An indexed database does not seem to offer the same convenient mechanism for such notifications. Do I need to use localStorageto send notifications to other tabs when making changes to the indexed database? The only alternative could be a survey that is clearly inferior to events storage.

+4
source share
1 answer

The indexed database does not have the current observer API. However, it is on the feature request list and there are similar offers from both Mozilla and Google.

https://github.com/w3c/IndexedDB/issues/51

In other words: yes, you need to create some kind of custom internetworking mechanism, such as polling, storage events, setting up MessageChannel (Chrome), BroadcastChannel (Firefox) links or using Service Worker as a relay between clients.


NEWS FLASH!

Chrome API Indexed DB Observers. chrome --enable-experimental-web-platform-features, , . - github.

+11

Source: https://habr.com/ru/post/1612425/


All Articles