pendingWriteCounts method
A stream of getPendingWriteCount: it emits the count when it is listened to, and then a new count after the queue of pending writes changed (a write, an acknowledgement, a rejection, a change of the signed-in user).
A supported extension: the official SDKs have no equivalent.
Each call returns a new single-subscription stream; it does not replay earlier counts, but starts with the current one. The stream is throttled: the changes within 250 milliseconds are read together, so a queue that drains 100,000 writes emits at most 4 counts a second, the last one being the final count. A count equal to the previous one is not emitted. The stream closes when the instance is terminated; listened to on a terminated instance it fails with a FirestoreException (failed-precondition) and closes.
With a persistent cache that several clients share, the stream emits after the changes this client makes or is told about: a batch another client writes or sends is counted at the next emission or by getPendingWriteCount, not as it happens.
final int total = await firestore.getPendingWriteCount();
final StreamSubscription<int> progress = firestore.pendingWriteCounts().listen(
(int pending) => print('syncing ${total - pending} of $total'),
);
// ...
await progress.cancel();
Implementation
Stream<int> pendingWriteCounts() {
return client.pendingWriteCounts();
}