Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Official event Dexie.on('storagemutated') #1384

Merged
merged 1 commit into from
Sep 3, 2021
Merged

Conversation

dfahlander
Copy link
Collaborator

@dfahlander dfahlander commented Sep 3, 2021

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.

…stomEvent on window as "x-storagemutated-1".

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.

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 will still gain from this communication channel in case it still do not support BroadcastChannel.

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.

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.
@dfahlander dfahlander merged commit 0f2c780 into master Sep 3, 2021
@dfahlander dfahlander deleted the storagemutated-event branch September 3, 2021 09:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant