Update 6-data-storage/03-indexeddb/article.md

Co-authored-by: Muhammed Zakir <8190126+MuhammedZakir@users.noreply.github.com>
This commit is contained in:
Peter Kampjes 2020-09-18 14:42:44 -03:00 committed by GitHub
parent 7b88ad9a9c
commit d235632379
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -121,7 +121,7 @@ So there's a tab with an open connection to DB version `1`, while the second tab
The problem is that a database is shared between two tabs, as it's the same site, same origin. And it can't be both version `1` and `2`. To perform the update to version `2`, all connections to version 1 must be closed, including the one in the first tab.
In order to organize that, the `versionchange` event triggers on the "outdated" database object. We should listen for it and close the old database connection (and probably suggest the visitor reloads the page, to load the updated code).
In order to organize that, the `versionchange` event triggers on the "outdated" database object. We should listen for it and close the old database connection (and probably suggest a page reload, to load the updated code).
If we don't listen for the `versionchange` event and don't close the old connection, then the second, new connection won't be made. The `openRequest` object will emit the `blocked` event instead of `success`. So the second tab won't work.