Closed jzumbrun closed 1 year ago
This is due to the nature of promises which resolve only once, when there's a result (success or error). They don't pass thru following resultsets. IF You use pure firebase with callbacks everything works as exspected, since the callback will be called anytime new data arrives. A workaround would be to modify promises not to expire once they're fullfilled.
It seems in indexdDB if a write transaction is started but not completed before a read transaction is started, the read transaction will not contain the new data the right transaction creates. I can confirm this by calling
insert()
, then within itspromise.then()
call agetAll()
, thegetAll()
results do NOT contain the newly inserted data. See http://stackoverflow.com/questions/16424897/onsuccess-and-oncomplete-call-back-is-not-working-for-indexeddb-add-transactionMy work around was to pass an option to
insert()
, ieinsert({my_object}, true)
, where true will resolve the$q
withinthis.transaction.complete
instead of just withinreq.onsuccess()
:The only other way to make this work is to use the same transaction call that is suggested via the stackoverflow link above.
Either way the update and delete calls should probably have something similar, or these methods should by default always resolve their promises in their respective oncompletes instead of just onsuccess. Please let me know if there is another way to solve this. Thanks