kt-mvvm / com.dukescript.api.kt

Package com.dukescript.api.kt

Types

Action

class Action

Represents an operation callable from the user interface.

Model

open class Model

Holds internal data associated with provided kotlin object. Create using the Model factory method:

Functions

Model

fun Model(thiz: Provider): Model

Instantiates new Model associated with provided thiz object. The model holds all necessary data for communication with JavaScript (or any other) implementation. If you have an object that you want to mirror in the other side, create a class and implement Model.Provider - it has just a single read only property - implement it by instantiating the Model instance with a pointer to your object.

action

fun Provider.action(f: () -> Unit): Readable<Action>

Creates a handler to react on action happening in the user interface.

actionWithData

fun <T> Provider.actionWithData(f: (T?) -> Unit): Readable<Action>
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.

applyBindings

fun applyBindings(model: Provider, id: String? = null): Unit

Activates given Model in the current context.

computed

fun <T> Provider.computed(fn: () -> T): Readable<T>

Defines derived, computed property. Its value depends on other properties and is recomputed when those dependant properties change.

loadJSON

fun <T> Provider.loadJSON(baseUrl: String, onSuccess: (List<T>) -> Unit, onError: (Throwable) -> Unit = null, method: String = "GET", data: Any? = null, headers: Map<String, String>? = null, afterUrl: String? = null): Unit

Initializes an asynchronous REST connection and calls back when a result is obtained.

observable

fun <T> Provider.observable(initialValue: T, onChange: () -> Unit = null): Writable<T>

Defines an observable property.

observableList

fun <T> Provider.observableList(vararg items: T, onChange: () -> Unit = null): Readable<MutableList<T>>

Defines an observable array property.