LoopView
inline fun <TState : Any, TModel : Any, TArgs, TDependency, TAction> LoopView(builder: <Error class: unknown class><TState, TModel, TArgs, TDependency, TAction>, args: TArgs? = null, childOf: Set<<Error class: unknown class>> = emptySet(), scope: CoroutineScope = rememberCoroutineScope(), key: String? = TModel::class.qualifiedName, loopStateCollector: LoopStateCollector<TState, TModel, TArgs, TDependency, TAction> = LoopStateCollectors.Standard(), crossinline content: @Composable TState.(emit: (action: TAction) -> Unit) -> Unit)
Attach a com.ekezet.hurok.Loop to a @Composable block as a state receiver.
For example:
@Composable
fun ScoreScreenView() {
LoopView(ScoreScreenLoop) {
Column {
Text(text = playerName)
Text(text = score)
Button(onClick = { emit(OnUpdateScoreClick) }) {
Text(text = "Update score")
}
}
}
}Content copied to clipboard
Parameters
builder
used to create the underlying Loop
args
arguments to pass to the Loop when created or to apply when the Loop already exists
childOf
set of loops that serve as parents for this loop
scope
CoroutineScope for launching actions
key
used for storing the ViewModel
loopStateCollector
can provide different methods for collecting Loop state
content
composable function used by the Loop
Throws
when builder result is not a Loop instance