Last active
October 16, 2022 17:19
-
-
Save Daniel-sims/2d361a5bc123f0e437355b55fbdd244a to your computer and use it in GitHub Desktop.
Updating UI State with LoginSuccessful navigation event
This file contains hidden or 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
private fun attemptLogin() { | |
viewModelScope.launch { | |
if (listOf(validateEmail(), validatePassword()).allValid()) { | |
uiState = uiState.copy(loading = true) | |
authenticationRepository.login( | |
email = uiState.content.email, | |
password = uiState.content.password | |
).handleResult( | |
onError = { loginError -> | |
uiState = uiState.copy( | |
loading = false, | |
error = uiState.error.copy(loginError = loginError) | |
) | |
}, | |
onSuccess = { | |
uiState = uiState.copy( | |
navigationEvent = UiState.NavigationEvents.LoginSuccessful | |
) | |
} | |
) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment