-
-
Save 5AbhishekSaxena/a84b77cb35715b6cdc31b6e6ce523f27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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