MCPcopy Create free account
hub / github.com/NativeScript/firebase / transaction

Method transaction

packages/firebase-database/index.android.ts:507–535  ·  view source on GitHub ↗
(transactionUpdate: (currentData: object) => object, onComplete?: (error: FirebaseError, committed: boolean, finalResult: any) => void, applyLocally: boolean = true)

Source from the content-addressed store, hash-verified

505 });
506 }
507 transaction(transactionUpdate: (currentData: object) => object, onComplete?: (error: FirebaseError, committed: boolean, finalResult: any) => void, applyLocally: boolean = true): Promise<TransactionResult> {
508 return new Promise((resolve, reject) => {
509 NSDatabaseReference().transaction(
510 this.native,
511 applyLocally,
512 new org.nativescript.firebase.database.FirebaseDatabase.TransactionCallback({
513 doTransaction(data: any): any {
514 const newData = transactionUpdate(deserialize(data));
515 // TODO improve
516 return serializeItems(newData, true);
517 },
518 onComplete(error: com.google.firebase.database.DatabaseError, commited: boolean, snapshot: com.google.firebase.database.DataSnapshot): void {
519 const ss = DataSnapshot.fromNative(snapshot);
520 if (error) {
521 const err = FirebaseError.fromNative(error);
522 onComplete?.(err, commited, ss);
523 reject(err);
524 } else {
525 onComplete?.(null, commited, ss);
526 resolve({
527 commited,
528 snapshot: ss,
529 });
530 }
531 },
532 })
533 );
534 });
535 }
536 update(values: { [key: string]: any }, onComplete?: (error: FirebaseError) => void): Promise<void> {
537 return new Promise((resolve, reject) => {
538 NSDatabaseReference().update(

Callers

nothing calls this directly

Calls 1

transactionMethod · 0.65

Tested by

no test coverage detected