Skip to content

Instantly share code, notes, and snippets.

@RBusarow
Created December 28, 2019 21:23
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 RBusarow/743703a40b35ed4cd9fc410219cfb55f to your computer and use it in GitHub Desktop.
Save RBusarow/743703a40b35ed4cd9fc410219cfb55f to your computer and use it in GitHub Desktop.
example of a type-safe observer from ktx 2.2.0
val someLiveData : LiveData<String> = ...
viewModel.someLiveData.observe(this) { someString: String ->
// the value from this lambda is inferred as non-nullable
stringWhichIsNotNull = message
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment