DarshanGowda0 / GeoFlutterFire

:fire:GeoFlutterFire:fire: is an open-source library that allows you to store and query firestore documents based on their geographic location.
https://youtu.be/MYHVyl-juUk
MIT License
305 stars 261 forks source link

Support for QuerySnapshot.documentChanges #94

Open reyjexter opened 4 years ago

reyjexter commented 4 years ago

I think supporting this will be useful on implementation which you need to remove certain elements from UI when document is removed/deleted. Currently when using querySnapshot.documents, you are not able to tell if a document is added, modified, or removed.

What's the best way or at least a work around to implement this? Thanks

webertim commented 4 years ago

I did not implement anything like this, but still I think I have a suggestion: In Firestore every document has a unique documentId. So what you could do is holding a list of all these unique IDs and once you get a new documentList you could compare those document IDs with your current list. Then you can tell if documents are removed updated or deleted.

Hope this helps.

lukestokes94 commented 4 years ago

I do something similar to Tim's method with a Hive database which stores a list of unique document ID's.

In my widget build method I compare the list of document snapshots I get from Firestore against this list and then remove items which match, before this is passed to my Listbuilder.

When you delete or dismiss methods from your UI then you can add this unique ID to the database and then notify the parent widget to rebuild with a set state.

On Wed, 20 May 2020 at 13:26, Tim Weber notifications@github.com wrote:

I did not implement anything like this, but still I think I have a suggestion: In Firestore every document has a unique documentId. So what you could do is holding a list of all these unique IDs and once you get a new documentList you could compare those document IDs with your current list. Then you can tell if documents are removed updated or deleted.

Hope this helps.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/DarshanGowda0/GeoFlutterFire/issues/94#issuecomment-631441458, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFFPGU7M2GHFBQFXSBI4CCDRSPD7JANCNFSM4NBDPXMA .