Skip to content

Commit 86a3a6e

Browse files
committed
add new DataSnapshot properties on ios
1 parent dd7fb7c commit 86a3a6e

File tree

12 files changed

+38
-29
lines changed

12 files changed

+38
-29
lines changed

firebase-auth/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-auth",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-auth.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.8.20",
2929
"kotlinx-coroutines-core": "1.6.4"

firebase-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-common",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-common.js",
66
"scripts": {

firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/_decoders.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
package dev.gitlive.firebase
66

7-
import kotlinx.serialization.encoding.CompositeDecoder
87
import kotlinx.serialization.descriptors.PolymorphicKind
98
import kotlinx.serialization.descriptors.SerialDescriptor
109
import kotlinx.serialization.descriptors.StructureKind
10+
import kotlinx.serialization.encoding.CompositeDecoder
1111
import kotlin.js.Json
1212

1313
@Suppress("UNCHECKED_CAST_TO_EXTERNAL_INTERFACE")
@@ -24,7 +24,7 @@ actual fun FirebaseDecoder.structureDecoder(descriptor: SerialDescriptor): Compo
2424
}
2525
StructureKind.LIST ->
2626
when(value) {
27-
is Array<*> -> value
27+
is Array<*> -> value.toList()
2828
else -> (js("Object").entries(value) as Array<Array<Any>>)
2929
.asSequence()
3030
.sortedBy { (it) -> it.toString().toIntOrNull() }

firebase-config/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-config",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-config.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.8.20",
2929
"kotlinx-coroutines-core": "1.6.4"

firebase-crashlytics/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-crashlytics",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-crashlytics.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.6.10",
2929
"kotlinx-coroutines-core": "1.6.1-native-mt"

firebase-database/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-database",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-database.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.8.20",
2929
"kotlinx-coroutines-core": "1.6.4"

firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/database.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ package dev.gitlive.firebase.database
66

77
import cocoapods.FirebaseDatabase.*
88
import cocoapods.FirebaseDatabase.FIRDataEventType.*
9-
import dev.gitlive.firebase.encode
109
import dev.gitlive.firebase.Firebase
1110
import dev.gitlive.firebase.FirebaseApp
1211
import dev.gitlive.firebase.database.ChildEvent.Type
1312
import dev.gitlive.firebase.database.ChildEvent.Type.*
1413
import dev.gitlive.firebase.decode
14+
import dev.gitlive.firebase.encode
1515
import kotlinx.coroutines.CompletableDeferred
1616
import kotlinx.coroutines.FlowPreview
1717
import kotlinx.coroutines.channels.awaitClose
@@ -23,7 +23,8 @@ import kotlinx.coroutines.selects.select
2323
import kotlinx.serialization.DeserializationStrategy
2424
import kotlinx.serialization.KSerializer
2525
import kotlinx.serialization.SerializationStrategy
26-
import platform.Foundation.*
26+
import platform.Foundation.NSError
27+
import platform.Foundation.allObjects
2728
import kotlin.collections.component1
2829
import kotlin.collections.component2
2930

@@ -103,7 +104,7 @@ actual open class Query internal constructor(
103104
val handle = ios.observeEventType(
104105
FIRDataEventTypeValue,
105106
withBlock = { snapShot ->
106-
trySend(DataSnapshot(snapShot!!))
107+
trySend(DataSnapshot(snapShot!!, persistenceEnabled))
107108
}
108109
) { close(DatabaseException(it.toString(), null)) }
109110
awaitClose { ios.removeObserverWithHandle(handle) }
@@ -114,7 +115,7 @@ actual open class Query internal constructor(
114115
ios.observeEventType(
115116
type.toEventType(),
116117
andPreviousSiblingKeyWithBlock = { snapShot, key ->
117-
trySend(ChildEvent(DataSnapshot(snapShot!!), type, key))
118+
trySend(ChildEvent(DataSnapshot(snapShot!!, persistenceEnabled), type, key))
118119
}
119120
) { close(DatabaseException(it.toString(), null)) }
120121
}
@@ -168,7 +169,7 @@ actual class DatabaseReference internal constructor(
168169
if (error != null) {
169170
deferred.completeExceptionally(DatabaseException(error.toString(), null))
170171
} else {
171-
deferred.complete(DataSnapshot(snapshot!!))
172+
deferred.complete(DataSnapshot(snapshot!!, persistenceEnabled))
172173
}
173174
},
174175
withLocalEvents = false
@@ -178,20 +179,28 @@ actual class DatabaseReference internal constructor(
178179
}
179180

180181
@Suppress("UNCHECKED_CAST")
181-
actual class DataSnapshot internal constructor(val ios: FIRDataSnapshot) {
182+
actual class DataSnapshot internal constructor(
183+
val ios: FIRDataSnapshot,
184+
private val persistenceEnabled: Boolean
185+
) {
182186

183187
actual val exists get() = ios.exists()
184188

185189
actual val key: String? get() = ios.key
186190

191+
actual val ref: DatabaseReference get() = DatabaseReference(ios.ref, persistenceEnabled)
192+
193+
actual val value get() = ios.value
194+
187195
actual inline fun <reified T> value() =
188196
decode<T>(value = ios.value)
189197

190198
actual fun <T> value(strategy: DeserializationStrategy<T>) =
191199
decode(strategy, ios.value)
192200

193-
actual fun child(path: String) = DataSnapshot(ios.childSnapshotForPath(path))
194-
actual val children: Iterable<DataSnapshot> get() = ios.children.allObjects.map { DataSnapshot(it as FIRDataSnapshot) }
201+
actual fun child(path: String) = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled)
202+
actual val hasChildren get() = ios.hasChildren()
203+
actual val children: Iterable<DataSnapshot> get() = ios.children.allObjects.map { DataSnapshot(it as FIRDataSnapshot, persistenceEnabled) }
195204
}
196205

197206
actual class OnDisconnect internal constructor(

firebase-firestore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-firestore",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-firestore.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.8.20",
2929
"kotlinx-coroutines-core": "1.6.4"

firebase-functions/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-functions",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-functions.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.8.20",
2929
"kotlinx-coroutines-core": "1.6.4"

firebase-installations/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-installations",
3-
"version": "1.8.2",
3+
"version": "1.9.2",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-installations.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.8.2",
26+
"@gitlive/firebase-app": "1.9.2",
2727
"firebase": "9.19.1",
2828
"kotlin": "1.8.20",
2929
"kotlinx-coroutines-core": "1.6.4"

0 commit comments

Comments
 (0)