jsMain.dev.gitlive.firebase.remoteconfig.FirebaseRemoteConfigValue.kt Maven / Gradle / Ivy
Go to download
The Firebase Kotlin SDK is a Kotlin-first SDK for Firebase. It's API is similar to the Firebase Android SDK Kotlin Extensions but also supports multiplatform projects, enabling you to use Firebase directly from your common source targeting iOS, Android or JS.
package dev.gitlive.firebase.remoteconfig
import dev.gitlive.firebase.firebase
actual class FirebaseRemoteConfigValue(val js: firebase.remoteConfig.Value) {
actual fun asBoolean(): Boolean = rethrow { js.asBoolean() }
actual fun asByteArray(): ByteArray = rethrow { js.asString()?.encodeToByteArray() ?: byteArrayOf() }
actual fun asDouble(): Double = rethrow { js.asNumber().toDouble() }
actual fun asLong(): Long = rethrow { js.asNumber().toLong() }
actual fun asString(): String = rethrow { js.asString() ?: "" }
actual fun getSource(): ValueSource = rethrow { js.getSource().toSource() }
private fun String.toSource() = when (this) {
"default" -> ValueSource.Default
"remote" -> ValueSource.Remote
"static" -> ValueSource.Static
else -> error("Unknown ValueSource: $this")
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy