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

On Sun, Nov 18, 2012 at 7:29 AM, Kyaw Tun <kyawtun@yathit.com> 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

Received on Monday, 19 November 2012 15:55:23 UTC