getPendingWriteCount method

Future<int> getPendingWriteCount()

Returns the number of write batches of the signed-in user that the backend has not acknowledged or rejected yet.

A supported extension: the official SDKs have no equivalent; they only offer waitForPendingWrites and hasPendingWrites on a snapshot.

A batch is one call of set, update or delete, or one WriteBatch.commit; a transaction is not queued. The count is that of the current user's queue (the queue is per user) and, with a persistent cache that several clients share, includes the batches the other clients wrote for that user. It is cheap also with millions of pending writes: the memory cache knows it, and the SQLite cache counts the keys of an index once and then keeps the number in memory.

On a terminated instance the future fails with a FirestoreException (failed-precondition).

final int pending = await firestore.getPendingWriteCount();
print('$pending writes wait for the backend');

Implementation

Future<int> getPendingWriteCount() => pendingWriteCount();