kt-mvvm / com.dukescript.api.kt / actionWithData

actionWithData

inline fun <reified T> Provider.actionWithData(noinline f: (T?) -> Unit): Readable<Action>

Creates a handler to react on action happening in the user interface and provide identification of the interface element that triggered the action.

public var message: String? by observable(null) {
        messageChanges++
    }
val selectWord: Action by actionWithData { word: String? ->
        message = "The word ${word} has been selected"
    }

Parameters

f - one argument function to handle the operation

fun <T> Provider.actionWithData(type: Class<T>, f: (T?) -> Unit): Readable<Action>

Creates a handler to react on action happening in the user interface and provide identification of the interface element that triggered the action.

Parameters

type - the type of the interface element the function expects

f - one argument function to handle the operation