Created
June 22, 2022 18:18
-
-
Save Debdutta-Panda/5b6dc621701f0414e6ab68f3de1437dd to your computer and use it in GitHub Desktop.
ViewModel
This file contains hidden or 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 YourViewModel: ViewModel() { | |
| val uiScope = mutableStateOf<UIScope?>(null) | |
| private val counter = mutableStateOf(0) | |
| fun onButtonClick() { | |
| if((++counter.value)%2==1){ | |
| uiScope.scope { | |
| it.toaster?.toast(it.toaster.stringResource(R.string.click_again)) | |
| } | |
| } | |
| else{ | |
| uiScope.scope { | |
| it.navHostController?.popBackStack() | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment