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

Adding examples for “versionchange” and “blocked”. #133

Merged
merged 4 commits into from Jan 9, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 13 additions & 5 deletions index.bs
Expand Up @@ -320,20 +320,21 @@ function displayMessage() {
}
</pre>

Another way is to call the database's close method. Other code on your page
should react to the database's "close" event, so it knows the database is no
longer accessible.
Another way is to call the database's close method. However, you need to make
sure your app is aware of this, as subsiquent attempts to access the database
will fail.

<pre class=lang-javascript>
db.onversionchange = function() {
saveUnsavedData().then(function() {
db.close();
stopUsingTheDatabase();
});
};

db.addEventListener('close', function() {
function stopUsingTheDatabase() {
// Put the app into a state where it no longer uses the database.
});
}
</pre>

The new client (the one attempting the upgrade) can use the "blocked" event to
Expand Down Expand Up @@ -5212,6 +5213,13 @@ optional |forced flag|.
have its type set to "<code>close</code>". The event must not
bubble or be cancelable.

<aside class=note>
The "<code>close</code>" event only fires if the connection closes
abnormally, e.g. if the user deletes browsing data, or there is
corruption, or an I/O error. If <code>close()</code> is called explicitly
the event <em>does not</em> fire.
</aside>

<aside class=advisement>
&#x1F6A7;
This behavior is new in this edition.
Expand Down