Hi guys, what is the best way to return a `List&lt...
# announcements
j
Hi guys, what is the best way to return a
List<String>
from a coroutine? My current code is this one but its kinda slow and affects my UI in android
Copy code
fun fetchUsers(): List<String> {
    val heartbeatApi = HeartbeatApi()
    val users = runBlocking {
        withContext(Dispatchers.Default) {heartbeatApi.fetchUsers() }
    }
    return users
}
i
You should not uses Default and runBlocking.
j
What can you suggest? I needed something that has the capability of returning a
List<String
i
e
The network and data task run in Dispatchers.IO