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

commonMain.internal.actions.IsTouchedAction.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.AbsolutePathFragment
import io.kform.FormManager
import io.kform.internal.AccessIsTouched
import io.kform.internal.AccessValueStateTree
import io.kform.internal.ActionAccessType
import io.kform.internal.StateImpl

/** Action that returns whether at least one value matching [path] has been touched. */
internal class IsTouchedAction(formManager: FormManager, private val path: AbsolutePath) :
    ValueStateAction(formManager) {
    override fun toString() = "IsTouched($path)"

    override val accesses =
        listOf(AccessValueStateTree(ActionAccessType.Read), AccessIsTouched(ActionAccessType.Read))
    override val accessedPaths = listOf(path + AbsolutePathFragment.RecursiveWildcard)

    override suspend fun run(): Boolean =
        stateInfo(path).any { info -> (info.state as StateImpl).isTouched }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy