Skip to content

Commit 2db160f

Browse files
committed
Add MetadataChanges optional parameter
1 parent 69c9f11 commit 2db160f

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

firebase-firestore/ktx/api.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ package com.google.firebase.firestore.ktx {
1010
method @Nullable public static inline <reified T> T getField(@NonNull com.google.firebase.firestore.DocumentSnapshot, @NonNull com.google.firebase.firestore.FieldPath fieldPath);
1111
method @Nullable public static inline <reified T> T getField(@NonNull com.google.firebase.firestore.DocumentSnapshot, @NonNull com.google.firebase.firestore.FieldPath fieldPath, @NonNull com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior);
1212
method @NonNull public static com.google.firebase.firestore.FirebaseFirestore getFirestore(@NonNull com.google.firebase.ktx.Firebase);
13-
method @NonNull public static kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.DocumentSnapshot> toFlow(@NonNull com.google.firebase.firestore.DocumentReference);
14-
method @NonNull public static kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.QuerySnapshot> toFlow(@NonNull com.google.firebase.firestore.Query);
13+
method @NonNull public static kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.DocumentSnapshot> toFlow(@NonNull com.google.firebase.firestore.DocumentReference, @NonNull com.google.firebase.firestore.MetadataChanges metadataChanges = com.google.firebase.firestore.MetadataChanges.EXCLUDE);
14+
method @NonNull public static kotlinx.coroutines.flow.Flow<com.google.firebase.firestore.QuerySnapshot> toFlow(@NonNull com.google.firebase.firestore.Query, @NonNull com.google.firebase.firestore.MetadataChanges metadataChanges = com.google.firebase.firestore.MetadataChanges.EXCLUDE);
1515
method @Nullable public static inline <reified T> T toObject(@NonNull com.google.firebase.firestore.DocumentSnapshot);
1616
method @Nullable public static inline <reified T> T toObject(@NonNull com.google.firebase.firestore.DocumentSnapshot, @NonNull com.google.firebase.firestore.DocumentSnapshot.ServerTimestampBehavior serverTimestampBehavior);
1717
method @NonNull public static inline <reified T> T toObject(@NonNull com.google.firebase.firestore.QueryDocumentSnapshot);

firebase-firestore/ktx/src/main/kotlin/com/google/firebase/firestore/ktx/Firestore.kt

+7-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import com.google.firebase.firestore.Query
2626
import com.google.firebase.firestore.QueryDocumentSnapshot
2727
import com.google.firebase.firestore.QuerySnapshot
2828
import com.google.firebase.firestore.FirebaseFirestoreSettings
29+
import com.google.firebase.firestore.MetadataChanges
2930

3031
import com.google.firebase.ktx.Firebase
3132
import com.google.firebase.platforminfo.LibraryVersionComponent
@@ -170,9 +171,10 @@ class FirebaseFirestoreKtxRegistrar : ComponentRegistrar {
170171

171172
/**
172173
* Attach a snapshotListener to a DocumentReference and use it as a coroutine flow
174+
* @param metadataChanges Indicates whether metadata-only changes
173175
*/
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 ->
176178
if (value != null && value.exists()) {
177179
offer(value)
178180
} else if (error != null) {
@@ -186,9 +188,10 @@ fun DocumentReference.toFlow() = callbackFlow {
186188

187189
/**
188190
* Attach a snapshotListener to a Query and use it as a coroutine flow
191+
* @param metadataChanges Indicates whether metadata-only changes
189192
*/
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 ->
192195
if (value != null) {
193196
offer(value)
194197
} else if (error != null) {

0 commit comments

Comments
 (0)