Skip to content

Instantly share code, notes, and snippets.

@saqib-github-commits
Last active April 28, 2023 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saqib-github-commits/1c4932456132df1a23c25617b91a0a6f to your computer and use it in GitHub Desktop.
Save saqib-github-commits/1c4932456132df1a23c25617b91a0a6f to your computer and use it in GitHub Desktop.
class LaunchedEffectTestViewModel : ViewModel() {
private var _snackbarCount = MutableStateFlow(1)
val snackbarCount: StateFlow<Int> get() = _snackbarCount
init {
viewModelScope.launch {
var displayCount = 1
while (displayCount < 3) {
delay(1000L)
displayCount += 1
_snackbarCount.value = displayCount
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment