commonMain.dev.gitlive.firebase.firestore.helpers.kt Maven / Gradle / Ivy
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 - 2025 Weber Informatics LLC | Privacy Policy