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

loadJSON

inline fun <reified T> Provider.loadJSON(baseUrl: String, noinline onSuccess: (List<T>) -> Unit, noinline 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.

loadJSON("http://example.com/message=Hello World!", { arr: List<MsgModel> ->
    message = arr[0].message
})