useFlow

fun <T> ComponentScope.useFlow(stateFlow: StateFlow<T>): T

Uses the current value of a given stateFlow in a Litho Kotlin component.

The flow will be collected on the CoroutineScope given by getTreeProp, and will be canceled when this component is detached.


fun <T> ComponentScope.useFlow(initialValue: () -> T, vararg keys: Any?, flowBlock: suspend () -> StateFlow<T>): T

Uses the collection of a StateFlow that is dynamically supplied by flowBlock, which will be executed whenever the given keys change.

The state flow will be collected on the CoroutineScope given by getTreeProp, and will be canceled when this component is detached or if any keys change.


fun <T> ComponentScope.useFlow(initialValue: () -> T, flowBlock: suspend () -> StateFlow<T>)

Deprecated (with error)

useFlow must provide 'keys' parameter that determines whether the existing flow will be canceled, and the new flow will be collected

Uses the collection of a StateFlow that is dynamically supplied by flowBlock.

It is an error to call ComponentScope.useFlow without keys parameter.