All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jsMain.dev.gitlive.firebase.database.ServerValue.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.

There is a newer version: 2.1.0
Show newest version
package dev.gitlive.firebase.database

import dev.gitlive.firebase.database.externals.serverTimestamp
import kotlinx.serialization.Serializable
import dev.gitlive.firebase.database.externals.increment as jsIncrement

/** Represents a Firebase ServerValue. */
@Serializable(with = ServerValueSerializer::class)
actual class ServerValue internal actual constructor(
    internal actual val nativeValue: Any
){
    actual companion object {
        actual val TIMESTAMP: ServerValue get() = ServerValue(serverTimestamp())
        actual fun increment(delta: Double): ServerValue = ServerValue(jsIncrement(delta))
    }

    override fun equals(other: Any?): Boolean =
        this === other || other is ServerValue && nativeValue == other.nativeValue
    override fun hashCode(): Int = nativeValue.hashCode()
    override fun toString(): String = "ServerValue($nativeValue)"
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy