commons/ui / com.vmadalin.commons.ui.extensions / androidx.lifecycle.LifecycleOwner / observe

observe

fun <T> LifecycleOwner.observe(liveData: LiveData<T>, observer: (T) -> Unit): Unit

Adds the given observer to the observers list within the lifespan of the given owner. The events are dispatched on the main thread. If LiveData already has data set, it will be delivered to the observer.

Parameters

liveData - The liveData to observe.

observer - The observer that will receive the events.

See Also

LiveData.observe

fun <T> LifecycleOwner.observe(liveData: MutableLiveData<T>, observer: (T) -> Unit): Unit

Adds the given observer to the observers list within the lifespan of the given owner. The events are dispatched on the main thread. If LiveData already has data set, it will be delivered to the observer.

Parameters

liveData - The mutableLiveData to observe.

observer - The observer that will receive the events.

See Also

MutableLiveData.observe