commonMain.internal.actions.GetCloneAction.kt Maven / Gradle / Ivy
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)
}
}