LoopView
inline fun <TState, TModel : Any, TArgs, TDependency, TAction> LoopView(builder: <Error class: unknown class><TState, TModel, TArgs, TDependency, TAction>, args: TArgs? = null, parentEmitter: <Error class: unknown class>? = null, scope: CoroutineScope = rememberCoroutineScope(), key: String? = TModel::class.qualifiedName, crossinline content: @Composable TState.() -> Unit)
Attach a 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
parentEmitter
parent emitter, usually another Loop instance
scope
CoroutineScope for launching actions
key
used for storing the ViewModel
content
composable function used by the Loop
Throws
when builder result is not a Loop instance