Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I wait until an IndexedDB instance is closed?

The IndexedDB method close is synchronous, how can I wait until close has finished? My usecase is that I close IndexedDB after automated tests and then before the next test, delete the database and re-open it.

The problem I'm seeing is that sometimes indexedDB.deleteDatabase fires the blocked event because the database hasn't yet been closed asynchronously (as you can see from deleteDatabase's documentation that I linked to). What I'm not entirely sure about is if the database will still be deleted in this case, despite the blocked event being fired.

like image 869
aknuds1 Avatar asked Nov 02 '22 15:11

aknuds1


1 Answers

You don't need to wait for close completed events, just close, delete the database and re-open it.

As you can see in IndexedDB API doc, close method does not dispatch completed event, but database delete method does. Anyways you don't need to listen these events.

like image 157
Kyaw Tun Avatar answered Nov 09 '22 09:11

Kyaw Tun