Skip to content

Instantly share code, notes, and snippets.

@vodamiro
Created April 11, 2019 14:11
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/11e2ec25a9a60c2c4696df52af572c4b to your computer and use it in GitHub Desktop.
Save vodamiro/11e2ec25a9a60c2c4696df52af572c4b 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