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

commonMain.dev.gitlive.firebase.firestore.helpers.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.firestore

/** Helper method to perform an update operation in Android and JS. */
internal fun  performUpdate(
    fieldsAndValues: Array>,
    encodeField: (T) -> K,
    encodeValue: (Any?) -> Any?,
    update: (K, Any?, Array) -> R
) : R? =
    fieldsAndValues.takeUnless { fieldsAndValues.isEmpty() }
        ?.map { (field, value) -> encodeField(field) to value?.let { encodeValue(it) } }
        ?.let { encoded ->
            update(
                encoded[0].first,
                encoded[0].second,
                encoded.drop(1).flatMap { (field, value) -> listOf(field, value) }.toTypedArray()
            )
        }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy