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

divkit.dsl.Trigger.kt Maven / Gradle / Ivy

Go to download

DivKit is an open source Server-Driven UI (SDUI) framework. SDUI is a an emerging technique that leverage the server to build the user interfaces of their mobile app.

There is a newer version: 30.19.0
Show newest version
@file:Suppress(
    "unused",
    "UNUSED_PARAMETER",
)

package divkit.dsl

import com.fasterxml.jackson.annotation.JsonAnyGetter
import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonValue
import divkit.dsl.annotation.*
import divkit.dsl.core.*
import divkit.dsl.scope.*
import kotlin.Any
import kotlin.String
import kotlin.Suppress
import kotlin.collections.List
import kotlin.collections.Map

/**
 * A trigger that causes an action when activated.
 * 
 * Can be created using the method [trigger].
 * 
 * Required parameters: `condition, actions`.
 */
@Generated
class Trigger internal constructor(
    @JsonIgnore
    val properties: Properties,
) {
    @JsonAnyGetter
    internal fun getJsonProperties(): Map = properties.mergeWith(emptyMap())

    operator fun plus(additive: Properties): Trigger = Trigger(
        Properties(
            actions = additive.actions ?: properties.actions,
            condition = additive.condition ?: properties.condition,
            mode = additive.mode ?: properties.mode,
        )
    )

    class Properties internal constructor(
        /**
         * Action when a trigger is activated.
         */
        val actions: Property>?,
        /**
         * Condition for activating a trigger. For example, `liked && subscribed`.
         */
        val condition: Property?,
        /**
         * Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • * Default value: `on_condition`. */ val mode: Property?, ) { internal fun mergeWith(properties: Map): Map { val result = mutableMapOf() result.putAll(properties) result.tryPutProperty("actions", actions) result.tryPutProperty("condition", condition) result.tryPutProperty("mode", mode) return result } } /** * Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • * * Possible values: [on_condition], [on_variable]. */ @Generated sealed interface Mode } /** * @param actions Action when a trigger is activated. * @param condition Condition for activating a trigger. For example, `liked && subscribed`. * @param mode Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • */ @Generated fun DivScope.trigger( `use named arguments`: Guard = Guard.instance, actions: List? = null, condition: Boolean? = null, mode: Trigger.Mode? = null, ): Trigger = Trigger( Trigger.Properties( actions = valueOrNull(actions), condition = valueOrNull(condition), mode = valueOrNull(mode), ) ) /** * @param actions Action when a trigger is activated. * @param condition Condition for activating a trigger. For example, `liked && subscribed`. * @param mode Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • */ @Generated fun DivScope.triggerProps( `use named arguments`: Guard = Guard.instance, actions: List? = null, condition: Boolean? = null, mode: Trigger.Mode? = null, ) = Trigger.Properties( actions = valueOrNull(actions), condition = valueOrNull(condition), mode = valueOrNull(mode), ) /** * @param actions Action when a trigger is activated. * @param condition Condition for activating a trigger. For example, `liked && subscribed`. * @param mode Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • */ @Generated fun TemplateScope.triggerRefs( `use named arguments`: Guard = Guard.instance, actions: ReferenceProperty>? = null, condition: ReferenceProperty? = null, mode: ReferenceProperty? = null, ) = Trigger.Properties( actions = actions, condition = condition, mode = mode, ) /** * @param actions Action when a trigger is activated. * @param condition Condition for activating a trigger. For example, `liked && subscribed`. * @param mode Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • */ @Generated fun Trigger.override( `use named arguments`: Guard = Guard.instance, actions: List? = null, condition: Boolean? = null, mode: Trigger.Mode? = null, ): Trigger = Trigger( Trigger.Properties( actions = valueOrNull(actions) ?: properties.actions, condition = valueOrNull(condition) ?: properties.condition, mode = valueOrNull(mode) ?: properties.mode, ) ) /** * @param actions Action when a trigger is activated. * @param condition Condition for activating a trigger. For example, `liked && subscribed`. * @param mode Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • */ @Generated fun Trigger.defer( `use named arguments`: Guard = Guard.instance, actions: ReferenceProperty>? = null, condition: ReferenceProperty? = null, mode: ReferenceProperty? = null, ): Trigger = Trigger( Trigger.Properties( actions = actions ?: properties.actions, condition = condition ?: properties.condition, mode = mode ?: properties.mode, ) ) /** * @param condition Condition for activating a trigger. For example, `liked && subscribed`. * @param mode Trigger activation mode:
  • `on_condition` — a trigger is activated when the condition changes from `false` to `true`;
  • `on_variable` — a trigger is activated when the condition is met and the variable value changes.
  • */ @Generated fun Trigger.evaluate( `use named arguments`: Guard = Guard.instance, condition: ExpressionProperty? = null, mode: ExpressionProperty? = null, ): Trigger = Trigger( Trigger.Properties( actions = properties.actions, condition = condition ?: properties.condition, mode = mode ?: properties.mode, ) ) @Generated fun Trigger.asList() = listOf(this) @Generated fun Trigger.Mode.asList() = listOf(this)




    © 2015 - 2024 Weber Informatics LLC | Privacy Policy