Re: [w3c/IndexedDB] Adding examples for “versionchange” and “blocked”. (#133)

inexorabletash commented on this pull request.



> +other tabs, you should use the "versionchange" event to close the connection to
+the database.
+
+<pre class=lang-javascript>
+db.onversionchange = function() {
+  // First, save any unsaved data:
+  saveUnsavedData().then(function() {
+    // Now you need to close the database.
+    // If the document isn't being actively used, it may be appropriate to reload:
+    if (!document.hasFocus()) {
+      location.reload();
+      // Reloading will close the database, and also reload with the new JavaScript
+      // and database definitions.
+    } else {
+      // Alternatively you may close the database and display a message to the
+      // user. You need to ensure this isn't a disruptive user experience.

No need for BroadcastChannel - the receiver of "versionchange" could pop up a modeless notification saying e.g. _"There's a new version of this web app available! Just click reload whenever you're ready."_

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/pull/133

Received on Friday, 6 January 2017 03:16:02 UTC