Created
December 28, 2019 21:23
-
-
Save RBusarow/743703a40b35ed4cd9fc410219cfb55f to your computer and use it in GitHub Desktop.
example of a type-safe observer from ktx 2.2.0
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
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