Skip to content

Instantly share code, notes, and snippets.

@devrath
Created October 9, 2021 14:48
Show Gist options
  • Select an option

  • Save devrath/29110a981e20b648fe5e58edd1951edf to your computer and use it in GitHub Desktop.

Select an option

Save devrath/29110a981e20b648fe5e58edd1951edf to your computer and use it in GitHub Desktop.
private fun simpleDemo() {
retrieveUserFromNetwork("111") {
println(it.userName)
}
}
private fun retrieveUserFromNetwork(
userId:String,
userRetrieved:(user:User) -> Unit
) {
thread {
Thread.sleep(1000)
val user = User(userId,"TestUser")
userRetrieved(user)
}
}
data class User(val userId:String,val userName:String)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment