tseisel
07/27/2019, 3:40 PMObserver
interface for LiveData
only has one observe
function, why should we write Observer { ... }
and not directly a lambda ?
Also, wouldn't it be nice if the parameter of the Observer
lambda would take the nullability of the T
value from LiveData into account ?
val nonNullable: LiveData<String> = ...
nonNullable.observe(this) { value: String -> ... }
val nullable: LiveData<String?> = ...
nullable.observe(this) { value: String? -> ... }
Mark McCormick
07/27/2019, 8:16 PMandroidx.lifecycle:lifecycle-livedata-ktx
and import androidx.lifecycle.observe
function that lets you write lambda directly as someLiveData.observe(viewLifecycleOwner).observe {}