-
-
Save PatilShreyas/e3b2d314cb31a6901b0e3a9e68734083 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
userRepository.findById(1, object: UserCallback { | |
override fun onUserFound(user: User) { | |
// Do something with `user`. | |
} | |
}) | |
} | |
interface UserRepository { | |
fun findById(id: Int, callback: UserCallback) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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