Created
June 27, 2023 14:10
-
-
Save tdcolvin/913e9d8df3dde0c9d6099701177e8e57 to your computer and use it in GitHub Desktop.
This file contains 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 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