observeWithoutOwner

fun <T> LiveData<T>.observeWithoutOwner(callback: (T) -> Unit)

Observe LiveData without particular owner (Activity eg.). Observer is removed when ViewModel is destroyed.

Parameters

callback

Lambda called when new value is dispatched to LiveData

fun <T : Any> DefaultValueLiveData<T>.observeWithoutOwner(callback: (T) -> Unit)

Observe DefaultValueLiveData without particular owner (Activity eg.). Observer is removed when ViewModel is destroyed.

Parameters

callback

Lambda called when new value is dispatched to LiveData

fun <T : Any> DefaultValueMediatorLiveData<T>.observeWithoutOwner(callback: (T) -> Unit)

Observe DefaultValueMediatorLiveData without particular owner (Activity eg.). Observer is removed when ViewModel is destroyed.

Parameters

callback

Lambda called when new value is dispatched to LiveData