Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class ViewModel {
val noClickButtonItem = ButtonItem() // Button with OnClickStrategy.None
val singleClickButtonItem = ButtonItem(onClickStrategy = SingleOnClickStrategy(runnable = ::operation))
val multipleClickButtonItem =
ButtonItem(onClickStrategy = MultipleOnClickStrategy(times = 3, runnable = ::operation))
}
@Composable
fun HomeScreen(viewModel: ViewModel) {
// The user's click behavior is mocked in the `also` block.
UIWithButton(viewModel.noClickButtonItem).also {
it.click() // No Output
}
UIWithButton(viewModel.singleClickButtonItem).also {
it.click() // Output: Operation Executed
}
UIWithButton(viewModel.multipleClickButtonItem).also {
it.click()
it.click()
it.click() // Output: Operation Executed
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment