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.
liveData
- The liveData to observe.
observer
- The observer that will receive the events.
See Also
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.
liveData
- The mutableLiveData to observe.
observer
- The observer that will receive the events.
See Also