Created
December 28, 2019 21:21
-
-
Save RBusarow/caacb4f02fffeb069231b1263067df88 to your computer and use it in GitHub Desktop.
example of a nullable LiveData observer
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> = ... | |
someLiveData.observe(this, Observer { someString: String? -> | |
// the value from the callback is always nullable | |
stringWhichIsNotNull = someString ?: "placeholder message" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment