Skip to content

Instantly share code, notes, and snippets.

@vodamiro
Created April 11, 2019 14:03
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 vodamiro/116951aa3f6a3b749becae835e9cbba3 to your computer and use it in GitHub Desktop.
Save vodamiro/116951aa3f6a3b749becae835e9cbba3 to your computer and use it in GitHub Desktop.
S_A_FunctionsAndLambdas.kt
data class User(val name)
interface UserDataSource {
fun getAllUsers(
onSuccess: (users: List<User>) -> Unit,
onError: (err: Throwable) -> Unit
)
}
// class UpdateDataSourceImpl: UserDataSource { .... }
UpdateDataSourceImpl().getAllUsers(
onSuccess = { users -> print(users) }, // here you consume success state
onError = { err -> print(err.message) } // here you consume error state
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment