observeEvent

inline fun <T> LiveData<SingleEvent<T>>.observeEvent(owner: LifecycleOwner, crossinline onEventUnhandledContent: (T) -> Unit)


fun <T, L : LiveData<SingleEvent<T>>> LifecycleOwner.observeEvent(liveData: L, body: (T) -> Unit = {})

Shorthand function that will observe the liveData using this as the LifecycleOwner. It uses EventObserver to observe the emitted values.

Parameters

liveData

the LiveData of SingleEvent to be observed

body

function to be invoked with the emitted value as a parameter