Hi all! I’m looking to call a REST API from an and...
# android
r
Hi all! I’m looking to call a REST API from an android app with coroutines. I could use some pointers to the best practices for how to call and propagate a JSON response from the api elsewhere in the application (business logic) which in turn will update the UI? Also, my more specific question is can I (and how) block the IO thread waiting for a synchronous HTTP request to return? How would I set this up from the caller? Thanks
a
Use Retrofit; there are many guides and tutorials out there for using it with suspend functions
j
Search YT for "Kotlin Coroutines in Practice" by Roman Elizarov from KotlinConf 2018. He gives practical examples of using coroutines in similar fashion of what you're seeking.
👍 1