Skip to content

Instantly share code, notes, and snippets.

@ifucolo
Created August 22, 2025 12:11
Show Gist options
  • Select an option

  • Save ifucolo/0aac368652ba6591193301771f8c27da to your computer and use it in GitHub Desktop.

Select an option

Save ifucolo/0aac368652ba6591193301771f8c27da to your computer and use it in GitHub Desktop.
class ChapletFlowViewModel(
private val challengeRepository: ChallengeRepository
) : ViewModel() {
private val _shouldCloseFlow = MutableSharedFlow<Boolean>()
val shouldCloseFlow: SharedFlow<Boolean> = _shouldCloseFlow
val backStack = mutableStateListOf<ChapletRoutes>()
init {
if (backStack.isEmpty()) {
backStack.add(ChapletRoutes.Start)
}
}
fun navigateTo(route: ChapletRoutes) {
backStack.add(route)
}
fun onChapletDone() {
viewModelScope.launch {
challengeRepository.updateChallengeV2(ChallengeId.CHAPLETS)
_shouldCloseFlow.emit(true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment