Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas

PatilShreyas/1-Old.kt Secret

Last active Dec 29, 2020
Embed
What would you like to do?
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