2.1.0
Added
database-version-changedevent, dispatched when another tab upgrades or deletes the database a
connection holds open. Previously the connection closed its handle silently, and the application
only found out when its next query failed withMigrationMismatchException. The event carries
databaseandversion, whereversionis the version the other tab is opening, ornullwhen
it is deleting the database.DB.onDatabaseVersionChanged()to listen for it, and theDatabaseVersionChangedclass exported
from the package.
The event is dispatched after the connection has closed its handle, so the other tab's upgrade is
never blocked while listeners run. Reloading the page is the right response. Querying again reopens
the database at the older version and fails:
DB.onDatabaseVersionChanged((event: DatabaseVersionChanged): void => {
if (confirm('A new version is available. Reload now?')) {
location.reload();
}
});