Package-level declarations

Functions

Link copied to clipboard
fun <T> View.observe(liveData: LiveData<T>, action: (T) -> Unit)
fun <T> ComponentActivity.observe(liveData: LiveData<T>, action: (T) -> Unit)
fun <T, V : ViewBinding> BaseFragment<V>.observe(liveData: LiveData<T>, action: (T) -> Unit)

NOTE: Only one observer at a time per value

Link copied to clipboard
fun <T> View.observeNullable(liveData: LiveData<T>, action: (T?) -> Unit)
fun <T> ComponentActivity.observeNullable(liveData: LiveData<T>, action: (T?) -> Unit)

NOTE: Only one observer at a time per value

fun <T, V : ViewBinding> BaseFragment<V>.observeNullable(liveData: LiveData<T>, action: (T?) -> Unit)

Attaches an observable to the root binding, instead of the fragment. This is more efficient as it will not call observe if the view is in the background.