Skip to content

Commit

Permalink
use export format to prevent https://stackoverflow.com/q/78429143/737857
Browse files Browse the repository at this point in the history
  • Loading branch information
nbransby committed May 5, 2024
1 parent b0dd8ec commit 90e4b5e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,15 @@ actual class DataSnapshot internal constructor(

actual val ref: DatabaseReference get() = DatabaseReference(android.ref, persistenceEnabled)

actual val value get() = android.value

actual val value get(): Any? {
check(!hasChildren) { "DataSnapshot.value can only be used for primitive values (snapshots without children)" }
return android.value
}
actual inline fun <reified T> value() =
decode<T>(value = android.value)
decode<T>(value = android.getValue(true))

actual fun <T> value(strategy: DeserializationStrategy<T>) =
decode(strategy, android.value)
decode(strategy, android.getValue(true))

actual fun child(path: String) = DataSnapshot(android.child(path), persistenceEnabled)
actual val hasChildren get() = android.hasChildren()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ actual class DataSnapshot internal constructor(
actual val value get() = ios.value

actual inline fun <reified T> value() =
decode<T>(value = ios.value)
decode<T>(value = ios.valueInExportFormat())

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

actual fun child(path: String) = DataSnapshot(ios.childSnapshotForPath(path), persistenceEnabled)
actual val hasChildren get() = ios.hasChildren()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ actual class DataSnapshot internal constructor(
}

actual inline fun <reified T> value() =
rethrow { decode<T>(value = js.`val`()) }
rethrow { decode<T>(value = js.exportVal()) }

actual fun <T> value(strategy: DeserializationStrategy<T>) =
rethrow { decode(strategy, js.`val`()) }
rethrow { decode(strategy, js.exportVal()) }

actual val exists get() = rethrow { js.exists() }
actual val key get() = rethrow { js.key }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ external interface DataSnapshot {
val size: Int
val ref: DatabaseReference
fun `val`(): Any
fun exportVal(): Any
fun exists(): Boolean
fun forEach(action: (a: DataSnapshot) -> Boolean): Boolean
fun child(path: String): DataSnapshot
Expand Down
24 changes: 12 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ kotlin.mpp.enableCInteropCommonization=true
kotlin.native.cacheKind=none

# Set to true to skip tests and even compilation of the iOS target.
skipIosTarget=false
skipIosTarget=true
# Skip iOS Tests
firebase-app.skipIosTests=false
# We are skipping auth ios tests due to an issue with keychain and simulator.
Expand Down Expand Up @@ -47,17 +47,17 @@ firebase-perf.skipJsTests=false
firebase-storage.skipJsTests=false

# Versions:
firebase-app.version=1.11.1
firebase-auth.version=1.11.1
firebase-common.version=1.11.1
firebase-config.version=1.11.1
firebase-database.version=1.11.1
firebase-firestore.version=1.11.1
firebase-functions.version=1.11.1
firebase-installations.version=1.11.1
firebase-perf.version=1.11.1
firebase-crashlytics.version=1.11.1
firebase-storage.version=1.11.1
firebase-app.version=1.11.2
firebase-auth.version=1.11.2
firebase-common.version=1.11.2
firebase-config.version=1.11.2
firebase-database.version=1.11.2
firebase-firestore.version=1.11.2
firebase-functions.version=1.11.2
firebase-installations.version=1.11.2
firebase-perf.version=1.11.2
firebase-crashlytics.version=1.11.2
firebase-storage.version=1.11.2

# Dependencies Versions:
gradlePluginVersion=8.1.3
Expand Down

0 comments on commit 90e4b5e

Please sign in to comment.