I want to use LiveData with Kotlin and have values that should not be null. How do you deal with this? Perhaps a wrapper around LiveData? Searching for good patterns here .. As
You can create an extension for LifecycleOwner
fun LifecycleOwner.observe(liveData: LiveData, lambda: (T) -> Unit) { liveData.observe(this, Observer { if (it != null) lambda(it) }) }
and then in your fragment/activity
observe(liveData) { ... }