Monkeypatch some broken semantics of Firebase transactions:
-
Transactions will no longer get aborted by a stray
set
orupdate
that happens to overlap them. -
When aborting the transaction (by returning undefined), the original value will be returned instead to force the server to check that the value wasn't stale, and retry if it was. If you really want to abort immediately then return
Firebase.ABORT_TRANSACTION_NOW
instead. -
Errors thrown by the update function will be caught and passed through to the completion callback and promise.
A standard Promise
class must be defined, either natively or via a polyfill.