flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

🐛 [cloud_firestore] FR: Source option for snapshots()

Open michalkubizna opened this issue 3 years ago • 1 comments

It's possible to pass "source" to GetOptions in the get() calls to make it retrieve the cache-only updates.

Implement the same feature for the real-time listener.

Use case: I’d like to create a comment section. A real-time listener doesn’t work with pagination in a dynamic collection like that since the moment comments are deleted or added the start value changes for each listener resulting in an inconsistent state.

A solution is to implement pagination using one-time get calls but that forces me to implement my own caching or state management solution to update the local data on the user’s device when they make changes (e.g add, delete, or like a comment). It’s a shame because Firestore implements its own caching solution and listening to the local cache would update fetched data with the user’s updates automatically.

michalkubizna avatar Dec 07 '22 12:12 michalkubizna

It seems this feature is being rolled out on the native SDKs (at least for android but presumably for iOS as well): https://github.com/firebase/firebase-android-sdk/issues/4498#issuecomment-1868156250

russellwheatley avatar Dec 27 '23 12:12 russellwheatley

Hello, it has actually been released for a couple of time:

  Stream<DocumentSnapshot<T>> snapshots({
    bool includeMetadataChanges = false,
    ListenSource source = ListenSource.defaultSource,
  });

I'm closing this :)

Lyokone avatar Jul 02 '24 08:07 Lyokone