@@ -26,6 +26,7 @@ import com.google.firebase.firestore.Query
26
26
import com.google.firebase.firestore.QueryDocumentSnapshot
27
27
import com.google.firebase.firestore.QuerySnapshot
28
28
import com.google.firebase.firestore.FirebaseFirestoreSettings
29
+ import com.google.firebase.firestore.MetadataChanges
29
30
30
31
import com.google.firebase.ktx.Firebase
31
32
import com.google.firebase.platforminfo.LibraryVersionComponent
@@ -170,9 +171,10 @@ class FirebaseFirestoreKtxRegistrar : ComponentRegistrar {
170
171
171
172
/* *
172
173
* Attach a snapshotListener to a DocumentReference and use it as a coroutine flow
174
+ * @param metadataChanges Indicates whether metadata-only changes
173
175
*/
174
- fun DocumentReference.toFlow () = callbackFlow {
175
- val listener = addSnapshotListener { value, error ->
176
+ fun DocumentReference.toFlow (metadataChanges : MetadataChanges = MetadataChanges . EXCLUDE ) = callbackFlow {
177
+ val listener = addSnapshotListener(metadataChanges) { value, error ->
176
178
if (value != null && value.exists()) {
177
179
offer(value)
178
180
} else if (error != null ) {
@@ -186,9 +188,10 @@ fun DocumentReference.toFlow() = callbackFlow {
186
188
187
189
/* *
188
190
* Attach a snapshotListener to a Query and use it as a coroutine flow
191
+ * @param metadataChanges Indicates whether metadata-only changes
189
192
*/
190
- fun Query.toFlow () = callbackFlow {
191
- val listener = addSnapshotListener { value, error ->
193
+ fun Query.toFlow (metadataChanges : MetadataChanges = MetadataChanges . EXCLUDE ) = callbackFlow {
194
+ val listener = addSnapshotListener(metadataChanges) { value, error ->
192
195
if (value != null ) {
193
196
offer(value)
194
197
} else if (error != null ) {
0 commit comments