[IndexedDB] Can IDBTransaction.oncomplete callback be used as active state?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[IndexedDB] Can IDBTransaction.oncomplete callback be used as active state?

Kyaw Tun
Transaction is active as long as I send request from the IDBRequest callback. Is there any other way to prevent committing?

If there any way to detect transaction active flag?

I expect IDBTransaction.oncomplete callback can be used to flag inactive state, but it is not according to my few test. Transaction is already inactive and cannot be use even before receiving oncomplete callback. 
Reply | Threaded
Open this post in threaded view
|

Re: [IndexedDB] Can IDBTransaction.oncomplete callback be used as active state?

Kyle Huey-2
On Sun, Nov 18, 2012 at 7:29 AM, Kyaw Tun <[hidden email]> wrote:
Transaction is active as long as I send request from the IDBRequest callback. Is there any other way to prevent committing?

No.  If at any point your JavaScript finishes executing there are no running or pending requests the transaction becomes inactive.
 
If there any way to detect transaction active flag?

Not directly.  Attempting to place a new request will fail with a TransactionInactiveError though.
 
I expect IDBTransaction.oncomplete callback can be used to flag inactive state, but it is not according to my few test. Transaction is already inactive and cannot be use even before receiving oncomplete callback. 

oncomplete is called after the transaction is committed.  The transition from active to inactive is what starts committing the transaction, so oncomplete is far too late to determine that.

- Kyle