Skip to content

Instantly share code, notes, and snippets.

@tdcolvin
Created June 27, 2023 14:10
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 tdcolvin/913e9d8df3dde0c9d6099701177e8e57 to your computer and use it in GitHub Desktop.
Save tdcolvin/913e9d8df3dde0c9d6099701177e8e57 to your computer and use it in GitHub Desktop.
class AddEditPlanetViewModel @Inject constructor(
private val addPlanetUseCase: AddPlanetUseCase,
...
): ViewModel() {
...
fun savePlanet() {
viewModelScope.launch {
addPlanetUseCase(
Planet(
planetId = planetId,
name = _uiState.value.planetName,
distanceLy = uiState.value.planetDistanceLy,
discovered = uiState.value.planetDiscovered
)
)
_uiState.update { it.copy(isPlanetSaved = true) }
}
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment