Skip to content

Commit 2e51a63

Browse files
committed
return non nullable snapshots
1 parent 31d1553 commit 2e51a63

File tree

1 file changed

+4
-8
lines changed
  • firebase-firestore/ktx/src/main/kotlin/com/google/firebase/firestore/ktx

1 file changed

+4
-8
lines changed

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

+4-8
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,12 @@ class FirebaseFirestoreKtxRegistrar : ComponentRegistrar {
186186
fun DocumentReference.toFlow(
187187
metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE,
188188
bufferCapacity: Int? = Channel.CONFLATED
189-
): Flow<DocumentSnapshot?> {
189+
): Flow<DocumentSnapshot> {
190190
val flow = callbackFlow {
191191
val registration = addSnapshotListener(metadataChanges) { snapshot, exception ->
192192
if (exception != null) {
193193
cancel(message = "Error getting DocumentReference snapshot", cause = exception)
194-
}
195-
196-
if (snapshot != null) {
194+
} else if (snapshot != null) {
197195
trySend(snapshot)
198196
}
199197
}
@@ -220,14 +218,12 @@ fun DocumentReference.toFlow(
220218
fun Query.toFlow(
221219
metadataChanges: MetadataChanges = MetadataChanges.EXCLUDE,
222220
bufferCapacity: Int? = Channel.CONFLATED
223-
): Flow<QuerySnapshot?> {
221+
): Flow<QuerySnapshot> {
224222
val flow = callbackFlow {
225223
val registration = addSnapshotListener(metadataChanges) { snapshot, exception ->
226224
if (exception != null) {
227225
cancel(message = "Error getting Query snapshot", cause = exception)
228-
}
229-
230-
if (snapshot != null) {
226+
} else if (snapshot != null) {
231227
trySend(snapshot)
232228
}
233229
}

0 commit comments

Comments
 (0)