I use two different events to respond to a response when an IndexedDB transaction completes or completes:
Let's say ... db: IDBDatabase object, tr: IDBTransaction object, os: IDBObjectStore object
tr = db.transaction(os_name,'readwrite');
os = tr.objectStore();
case 1:
r = os.openCursor();
r.onsuccess = function(){
if(r.result){
callback_for_result_fetched();
r.result.continue;
}else callback_for_transaction_finish();
}
case 2:
tr.oncomplete = callback_for_transaction_finish();
It is a waste if both of them work the same. Can you tell me if there is a difference between the two?
source
share