Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Firestore document snapshot work?

when a new document is added, snapshot fetches all the documents including the new ones or only the newly added ones ? If it fetches all the documents every time then it will add to the billing cost. How to get around this problem ?

StreamBuilder(
          stream:Firestore.instance
              .collection('chat')
              .orderBy('timeStamp', descending: true).snapshots(),
          builder: (context, streamSnapshot) {}
);
like image 831
Niteesh Avatar asked Jun 21 '26 23:06

Niteesh


1 Answers

While your snapshots() listener stays active, the server actively monitors for changes that are relevant to your listener. When there are such changes it only sends you new documents, or documents that were changed, to your client. The client then merges those updates with its local data, and presents you with a new complete QuerySnapshot.

like image 50
Frank van Puffelen Avatar answered Jun 24 '26 13:06

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!