Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Last active December 29, 2020 14:49
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 PatilShreyas/e3b2d314cb31a6901b0e3a9e68734083 to your computer and use it in GitHub Desktop.
Save PatilShreyas/e3b2d314cb31a6901b0e3a9e68734083 to your computer and use it in GitHub Desktop.
fun main() {
userRepository.findById(1, object: UserCallback {
override fun onUserFound(user: User) {
// Do something with `user`.
}
})
}
interface UserRepository {
fun findById(id: Int, callback: UserCallback)
}
fun main() = runBlocking {
val user = userRepository.findById(1) // Blocking call
// Do something with `user`.
}
interface UserRepository {
suspend fun findById(id: Int): User
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment