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

Model

open class Model

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

class TestData : Model.Provider {
    override val objs = Model(this)

    public var value: Int by observable(0)
}

Types

Provider

interface Provider

Interface to implement by objects that willing to expose its properties (e.g. com.dukescript.api.kt.observable, com.dukescript.api.kt.observableList or com.dukescript.api.kt.computed) as Models. Trivial implementation can look like this:

Readable

class Readable<T>

Delegate for creating read-only property.

Writable

class Writable<T>

Delegate for creating read-write property.

Functions

loadJSON

fun <T> loadJSON(clazz: Class<T>, baseUrl: String, onSuccess: (List<T>) -> Unit, onError: (Throwable) -> Unit, method: String, data: Any?, headers: Map<String, String>?, afterUrl: String?): Unit

Helper method that is called by com.dukescript.api.kt.loadJSON.

observable

fun <T> observable(type: Class<T>, initialValue: T, onChange: () -> Unit): Writable<T>

Helper method. Called from com.dukescript.api.kt.observable.

observableList

fun <T> observableList(type: Class<T>, items: Array<out T>, onChange: () -> Unit): Readable<MutableList<T>>

Helper method. Called from com.dukescript.api.kt.observableList.