Skip to content

Instantly share code, notes, and snippets.

@le0nidas
Last active March 28, 2021 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save le0nidas/d3059cd70754aa2ecea3b8ffac9e9dab to your computer and use it in GitHub Desktop.
Save le0nidas/d3059cd70754aa2ecea3b8ffac9e9dab to your computer and use it in GitHub Desktop.
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