What is the main difference between using { includeMetadataChanges: true } in snapshot function and not using it at all, as I understood from docs it kind of more sensitive to change ?
import { doc, onSnapshot } from "firebase/firestore";
const unsub = onSnapshot(
doc(db, "cities", "SF"),
{ includeMetadataChanges: true },
(doc) => {
// ...
});
When you listen for values with includeMetadataChanges: true, your callback also gets invoked when only the metadata of a snapshot has changed. Specifically this may happen when the client has verified that there were no changes on the server (so fromCache becomes true) or when local writes have been committed on the server (and so hasPendingWrites becomes false).
Without the flag, you'd not be notified of those changes, as they're not commonly shown in the UI of the app (although they definitely can be).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With