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

commonMain.internal.actions.GetExternalContextAction.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.ExternalContextHandler
import io.kform.FormManager
import io.kform.internal.AccessExternalContext
import io.kform.internal.ActionAccessType

/**
 * Action that returns the external context with name [externalContextName] available to
 * validations.
 */
internal class GetExternalContextAction(
    formManager: FormManager,
    private val externalContextName: String,
    private val externalContextHandler: ExternalContextHandler
) : FormManagerAction(formManager) {
    override fun toString() = "GetExternalContext($externalContextName)"

    override val accesses = listOf(AccessExternalContext(ActionAccessType.Read))
    override val accessedPaths: List = emptyList()

    override suspend fun run(): T =
        @Suppress("UNCHECKED_CAST")
        externalContextHandler(formManager.externalContexts[externalContextName] as TContext)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy