Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
fun main(): Unit = runBlocking {
launch {
val tasks = downloadTasks()
printTasks(tasks)
}
}
private suspend fun downloadTasks() {
println("Downloading...")
// code that makes a network call and returns the list of tasks
return listOf(Task(1), Task(2), Task(3))
}
private fun printTasks(tasks: List<Task>) {
tasks.forEach { task -> println(task.id) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment