Skip to content

Instantly share code, notes, and snippets.

@RBusarow
Created December 28, 2019 21:21
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/caacb4f02fffeb069231b1263067df88 to your computer and use it in GitHub Desktop.
Save RBusarow/caacb4f02fffeb069231b1263067df88 to your computer and use it in GitHub Desktop.
example of a nullable LiveData observer
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