Skip to content

Instantly share code, notes, and snippets.

@Debdutta-Panda
Created June 22, 2022 18:18
Show Gist options
  • Select an option

  • Save Debdutta-Panda/5b6dc621701f0414e6ab68f3de1437dd to your computer and use it in GitHub Desktop.

Select an option

Save Debdutta-Panda/5b6dc621701f0414e6ab68f3de1437dd to your computer and use it in GitHub Desktop.
ViewModel
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