File tree Expand file tree Collapse file tree 5 files changed +14
-5
lines changed
firebase-common/src/jsMain/kotlin/dev/gitlive/firebase
androidMain/kotlin/dev/gitlive/firebase/firestore
commonMain/kotlin/dev/gitlive/firebase/firestore
jsMain/kotlin/dev/gitlive/firebase/firestore Expand file tree Collapse file tree 5 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ subprojects {
62
62
}
63
63
64
64
tasks.withType<Sign >().configureEach {
65
- onlyIf { ! project.gradle.startParameter.taskNames.contains(" publishToMavenLocal " ) }
65
+ onlyIf { ! project.gradle.startParameter.taskNames.any { " MavenLocal " in it } && ! project.gradle.startParameter.taskNames. contains(" publishToGitHubPackagesRepository " ) }
66
66
}
67
67
68
68
tasks {
Original file line number Diff line number Diff line change @@ -454,7 +454,7 @@ external object firebase {
454
454
fun update (field : String , value : Any? , vararg moreFieldsAndValues : Any? ): Promise <Unit >
455
455
fun update (field : FieldPath , value : Any? , vararg moreFieldsAndValues : Any? ): Promise <Unit >
456
456
fun delete (): Promise <Unit >
457
- fun onSnapshot (next : (snapshot: DocumentSnapshot ) -> Unit , error : (error: Error ) -> Unit ): ()-> Unit
457
+ fun onSnapshot (options : Json , next : (snapshot: DocumentSnapshot ) -> Unit , error : (error: Error ) -> Unit ): ()-> Unit
458
458
}
459
459
460
460
open class WriteBatch {
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import com.google.firebase.firestore.MetadataChanges
10
10
import com.google.firebase.firestore.SetOptions
11
11
import dev.gitlive.firebase.*
12
12
import kotlinx.coroutines.channels.awaitClose
13
+ import kotlinx.coroutines.flow.Flow
13
14
import kotlinx.coroutines.flow.callbackFlow
14
15
import kotlinx.coroutines.runBlocking
15
16
import kotlinx.coroutines.tasks.await
@@ -263,8 +264,11 @@ actual class DocumentReference(val android: com.google.firebase.firestore.Docume
263
264
actual suspend fun get () =
264
265
DocumentSnapshot (android.get().await())
265
266
266
- actual val snapshots get() = callbackFlow<DocumentSnapshot > {
267
- val listener = android.addSnapshotListener { snapshot, exception ->
267
+ actual val snapshots: Flow <DocumentSnapshot > get() = snapshots()
268
+
269
+ actual fun snapshots (includeMetadataChanges : Boolean ) = callbackFlow {
270
+ val metadataChanges = if (includeMetadataChanges) MetadataChanges .INCLUDE else MetadataChanges .EXCLUDE
271
+ val listener = android.addSnapshotListener(metadataChanges) { snapshot, exception ->
268
272
snapshot?.let { trySend(DocumentSnapshot (snapshot)) }
269
273
exception?.let { close(exception) }
270
274
}
Original file line number Diff line number Diff line change @@ -126,6 +126,7 @@ expect class DocumentReference {
126
126
val path: String
127
127
val snapshots: Flow <DocumentSnapshot >
128
128
val parent: CollectionReference
129
+ fun snapshots (includeMetadataChanges : Boolean = false): Flow <DocumentSnapshot >
129
130
130
131
fun collection (collectionPath : String ): CollectionReference
131
132
suspend fun get (): DocumentSnapshot
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import dev.gitlive.firebase.*
8
8
import kotlinx.coroutines.GlobalScope
9
9
import kotlinx.coroutines.await
10
10
import kotlinx.coroutines.channels.awaitClose
11
+ import kotlinx.coroutines.flow.Flow
11
12
import kotlinx.coroutines.flow.callbackFlow
12
13
import kotlinx.coroutines.promise
13
14
import kotlinx.serialization.DeserializationStrategy
@@ -234,8 +235,11 @@ actual class DocumentReference(val js: firebase.firestore.DocumentReference) {
234
235
235
236
actual suspend fun get () = rethrow { DocumentSnapshot (js.get().await()) }
236
237
237
- actual val snapshots get() = callbackFlow<DocumentSnapshot > {
238
+ actual val snapshots: Flow <DocumentSnapshot > get() = snapshots()
239
+
240
+ actual fun snapshots (includeMetadataChanges : Boolean ) = callbackFlow {
238
241
val unsubscribe = js.onSnapshot(
242
+ json(" includeMetadataChanges" to includeMetadataChanges),
239
243
{ trySend(DocumentSnapshot (it)) },
240
244
{ close(errorToException(it)) }
241
245
)
You can’t perform that action at this time.
0 commit comments