collectWithLifecycle

inline fun <T> LifecycleOwner.collectWithLifecycle(flow: Flow<T>, crossinline action: (T) -> Unit)

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

Parameters

action

The action to be executed when the value is changed.