bind

fun <S, W : Widget> W.bind(stateFlow: StateFlow<S>, removeChildren: Boolean = true, runImmediately: Boolean = true, factory: W.(S) -> Unit): W

An extension function which binds the widget to the given state flow.

Parameters

S

the state type

W

the widget type

stateFlow

the StateFlow instance

removeChildren

remove all children of the component

runImmediately

whether to run factory function immediately with the current state

factory

a function which re-creates the view based on the given state