@@ -248,10 +248,7 @@ public WriteBatch StartBatch() {
248
248
/// be invoked on the main thread.</param>
249
249
/// <returns>A task which completes when the transaction has committed.</returns>
250
250
public Task RunTransactionAsync ( Func < Transaction , Task > callback ) {
251
- Preconditions . CheckNotNull ( callback , nameof ( callback ) ) ;
252
- // Just pass through to the overload where the callback returns a Task<T>.
253
- return RunTransactionAsync ( transaction =>
254
- Util . MapResult < object > ( callback ( transaction ) , null ) ) ;
251
+ return RunTransactionAsync ( new TransactionOptions ( ) , callback ) ;
255
252
}
256
253
257
254
/// <summary>
@@ -276,8 +273,65 @@ public Task RunTransactionAsync(Func<Transaction, Task> callback) {
276
273
/// <returns>A task which completes when the transaction has committed. The result of the task
277
274
/// then contains the result of the callback.</returns>
278
275
public Task < T > RunTransactionAsync < T > ( Func < Transaction , Task < T > > callback ) {
276
+ return RunTransactionAsync ( new TransactionOptions ( ) , callback ) ;
277
+ }
278
+
279
+ /// <summary>
280
+ /// Runs a transaction asynchronously, with an asynchronous callback that returns a value.
281
+ /// The specified callback is executed for a newly-created transaction.
282
+ /// </summary>
283
+ /// <remarks>
284
+ /// <para><c>RunTransactionAsync</c> executes the given callback on the main thread and then
285
+ /// attempts to commit the changes applied within the transaction. If any document read within
286
+ /// the transaction has changed, the <paramref name="callback"/> will be retried. If it fails to
287
+ /// commit after the maximum number of attempts specified in the given <c>TransactionOptions</c>
288
+ /// object, the transaction will fail.</para>
289
+ ///
290
+ /// <para>The maximum number of writes allowed in a single transaction is 500, but note that
291
+ /// each usage of <see cref="FieldValue.ServerTimestamp"/>, <c>FieldValue.ArrayUnion</c>,
292
+ /// <c>FieldValue.ArrayRemove</c>, or <c>FieldValue.Increment</c> inside a transaction counts as
293
+ /// an additional write.</para>
294
+ /// </remarks>
295
+ ///
296
+ /// <typeparam name="T">The result type of the callback.</typeparam>
297
+ /// <param name="options">The transaction options for controlling execution. Must not be
298
+ /// <c>null</c>.</param>
299
+ /// <param name="callback">The callback to execute. Must not be <c>null</c>. The callback will
300
+ /// be invoked on the main thread.</param>
301
+ /// <returns>A task which completes when the transaction has committed. The result of the task
302
+ /// then contains the result of the callback.</returns>
303
+ public Task < T > RunTransactionAsync < T > ( TransactionOptions options , Func < Transaction , Task < T > > callback ) {
304
+ Preconditions . CheckNotNull ( options , nameof ( options ) ) ;
305
+ Preconditions . CheckNotNull ( callback , nameof ( callback ) ) ;
306
+ return WithFirestoreProxy ( proxy => _transactionManager . RunTransactionAsync ( options , callback ) ) ;
307
+ }
308
+
309
+ /// <summary>
310
+ /// Runs a transaction asynchronously, with an asynchronous callback that doesn't return a
311
+ /// value. The specified callback is executed for a newly-created transaction.
312
+ /// </summary>
313
+ /// <remarks>
314
+ /// <para><c>RunTransactionAsync</c> executes the given callback on the main thread and then
315
+ /// attempts to commit the changes applied within the transaction. If any document read within
316
+ /// the transaction has changed, the <paramref name="callback"/> will be retried. If it fails to
317
+ /// commit after the maximum number of attempts specified in the given <c>TransactionOptions</c>
318
+ /// object, the transaction will fail.</para>
319
+ ///
320
+ /// <para>The maximum number of writes allowed in a single transaction is 500, but note that
321
+ /// each usage of <see cref="FieldValue.ServerTimestamp"/>, <c>FieldValue.ArrayUnion</c>,
322
+ /// <c>FieldValue.ArrayRemove</c>, or <c>FieldValue.Increment</c> inside a transaction counts as
323
+ /// an additional write.</para>
324
+ /// </remarks>
325
+ /// <param name="options">The transaction options for controlling execution. Must not be
326
+ /// <c>null</c>.</param>
327
+ /// <param name="callback">The callback to execute. Must not be <c>null</c>. The callback will
328
+ /// be invoked on the main thread.</param>
329
+ /// <returns>A task which completes when the transaction has committed.</returns>
330
+ public Task RunTransactionAsync ( TransactionOptions options , Func < Transaction , Task > callback ) {
331
+ Preconditions . CheckNotNull ( options , nameof ( options ) ) ;
279
332
Preconditions . CheckNotNull ( callback , nameof ( callback ) ) ;
280
- return WithFirestoreProxy ( proxy => _transactionManager . RunTransactionAsync ( callback ) ) ;
333
+ // Just pass through to the overload where the callback returns a Task<T>.
334
+ return RunTransactionAsync ( options , transaction => Util . MapResult < object > ( callback ( transaction ) , null ) ) ;
281
335
}
282
336
283
337
private static SnapshotsInSyncCallbackMap snapshotsInSyncCallbacks = new SnapshotsInSyncCallbackMap ( ) ;
0 commit comments