Reputation: 1270
problem: the stream view shows old data for a brief moment. showing old data is useful on other streams, so I don't want to disable it for the entire project, but on one specific screen, it confuses the user.
I'm using Firebase Firestore for a flutter app, I want to disable It’s offline service only on one screen and one stream, not for the entire project, I know how to disable persistence on initialization, but I need to disable it only for a single query.
Upvotes: 0
Views: 1097
Reputation: 598728
You can't listen for a stream in a way that bypasses the local cache. But you can detect in your callback whether a document was instantiated from the cache (and may be stale) by checking the DocumentSnapshot.metadata.isFromCache
property. If the isFromCache
is false, the snapshot is guaranteed to be up to date with the server.
Upvotes: 2