Created
February 24, 2021 12:09
-
-
Save TorkelV/8647bf105b529da5e50cc3890db8c8f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Query.asFlow(): Flow<QuerySnapshot> { | |
return callbackFlow { | |
val callback = addSnapshotListener { querySnapshot, ex -> | |
if (ex != null) { | |
close(ex) | |
} else { | |
offer(querySnapshot!!) | |
} | |
} | |
awaitClose { | |
callback.remove() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment