Official event Dexie.on('storagemutated') #1384
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Official event Dexie.on('storagemutated').
This change is a step to making dexie@3.2.0 an officially supported stable release where the observability communication channel can be official and documented.
The event was previously undocumented and had the name Dexie.on('txcommitted'). The event is the channel that communicates changes on indexeddb databases to enable
liveQuery()
to detect changes across service worker, windows and tabs. Event is propagated across peers using BroadcastChannel on browsers supporting it, and "storage" event on IE and Safari.Breaking Change of undocumented event name: The renaming of the event is a "breaking change" from previous beta versions (dexie@3.1.x-beta.x and dexie@3.2.x-beta.x) even thought the event hasn't been any part of the officially supported API surface before. The name of the BroadcastChannel and storage event used is also changed with this commit. Now we're using "x-storagemutated-1" as the BroadcastChannel event, and in case storage event is used, we use a localStorage property with that name there as well. Currently the use of "storage" event is not working on Safari as it has a recent bug. However, the bug has been resolved in webkit and a future version of Safari may still gain from this "fallback communication channel".
This commit also improves observability in a rare use case when "dexie" module is imported multiple times (possibly with different versions of the package) as it also propagates on window/self event target and not just Dexie static.