December 2017
Intermediate to advanced
260 pages
7h 34m
English
In asynchronous mode, the thread is not blocked until completion. It doesn't wait for a response, instead a callback is called when the response is returned, as shown in the following code snippet:
"https://newsapi.org/".httpGet().responseString { request, response, result -> //do something with response when (result) { is Result.Failure -> { error = result.getAs() } is Result.Success -> { data = result.getAs() } } }
In the preceding example, we send a GET request to the URL and received the response as a callback with success or failure flags.
Read now
Unlock full access