observeWhile
inline fun <T> LiveData<T>.observeWhile(lifecycleOwner: LifecycleOwner, crossinline onChanged: (T) -> Boolean): Observer<T>
Content copied to clipboard
Observes this LiveData as long as onChanged returns true
and returns the observer. The returned observer can be used to stop observing the LiveData when a callback is no longer desired. It is safe to remove the observer while it is executing or after onChanged returns true
.
Parameters
lifecycleOwner
The owner of the observer.
onChanged
Called for each change as long as this lambda returns true
.