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

commonMain.internal.actions.GetCloneAction.kt Maven / Gradle / Ivy

There is a newer version: 0.23.0
Show newest version
package io.kform.internal.actions

import io.kform.AbsolutePath
import io.kform.FormManager
import io.kform.ValueInfo
import kotlinx.coroutines.flow.single

/** Action that returns a clone of the single value matching [path]. */
internal class GetCloneAction(formManager: FormManager, path: AbsolutePath) :
    ReadValueStateAction(formManager, path) {
    override fun toString() = "GetClone($path)"

    override suspend fun run(): T {
        @Suppress("UNCHECKED_CAST") val info = valueInfo(path).single() as ValueInfo
        return info.schema.clone(info.value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy