File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
fireflow/src/main/java/io/github/horaciocome1/fireflow Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ import kotlin.coroutines.CoroutineContext
32
32
inline fun <reified T > Query.asFlow (
33
33
coroutineContext : CoroutineContext = Dispatchers .IO ,
34
34
): Flow <MutableList <T >> = snapshotAsFlow(coroutineContext).map {
35
- it.toObjects(T ::class .java)
35
+ it? .toObjects(T ::class .java) ? : mutableListOf ( )
36
36
}
37
37
38
38
/* *
@@ -43,5 +43,5 @@ inline fun <reified T> Query.asFlow(
43
43
inline fun <reified T > DocumentReference.asFlow (
44
44
coroutineContext : CoroutineContext = Dispatchers .IO ,
45
45
): Flow <T ?> = snapshotAsFlow(coroutineContext).map {
46
- it.toObject(T ::class .java)
46
+ it? .toObject(T ::class .java)
47
47
}
Original file line number Diff line number Diff line change @@ -38,10 +38,10 @@ import kotlin.coroutines.CoroutineContext
38
38
@ExperimentalCoroutinesApi
39
39
fun DocumentReference.snapshotAsFlow (
40
40
coroutineContext : CoroutineContext = Dispatchers .IO ,
41
- ): Flow <DocumentSnapshot > = callbackFlow {
41
+ ): Flow <DocumentSnapshot ? > = callbackFlow {
42
42
try {
43
43
val listener = EventListener <DocumentSnapshot > { snapshot, error ->
44
- if (error != null || snapshot == null ) {
44
+ if (error != null ) {
45
45
close(error)
46
46
return @EventListener
47
47
}
@@ -63,10 +63,10 @@ fun DocumentReference.snapshotAsFlow(
63
63
@ExperimentalCoroutinesApi
64
64
fun Query.snapshotAsFlow (
65
65
coroutineContext : CoroutineContext = Dispatchers .IO ,
66
- ): Flow <QuerySnapshot > = callbackFlow {
66
+ ): Flow <QuerySnapshot ? > = callbackFlow {
67
67
try {
68
68
val listener = EventListener <QuerySnapshot > { snapshot, error ->
69
- if (error != null || snapshot == null ) {
69
+ if (error != null ) {
70
70
close(error)
71
71
return @EventListener
72
72
}
You can’t perform that action at this time.
0 commit comments