observeOnLifecycle

fun <T> WithState<T>.observeOnLifecycle(lifecycleOwner: LifecycleOwner, filter: suspend (T) -> Boolean = { true }, onNext: (T) -> Unit): Job

Observes WithState on the lifecycle of a LifecycleOwner

Parameters

lifecycleOwner

The LifecycleOwner on which to observe.

filter

A filtering function to filter out certain values.

onNext

Action to execute when a new value is observed.


fun <T, R> WithState<T>.observeOnLifecycle(lifecycleOwner: LifecycleOwner, filter: suspend (T) -> Boolean = { true }, transform: suspend (T) -> R, onNext: (R) -> Unit): Job

Observes WithState on the lifecycle of a LifecycleOwner by transforming the observed value.

Parameters

lifecycleOwner

The LifecycleOwner on which to observe.

filter

A filtering function to filter out certain values.

transform

Transforms the next value into a different value of type R.

onNext

Action to execute when a new value is observed.