observe

inline fun <T> LifecycleOwner.observe(liveData: LiveData<T>, crossinline action: (T) -> Unit)

Observe a LiveData and execute an action when the value is changed.

Parameters

action

The action to be executed when the value is changed.