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
// This is how to manage the errors returned by a use case using the Either monad | |
fun doLogin() { | |
val params = UseCaseCommonMainLogin.AuthenticationLoginParams( | |
username = localState.data.username, | |
password = localState.data.password, | |
) | |
useCaseCommonMainLogin.invoke(params, viewModelScope) { result -> | |
result.fold(::displayError, ::navigateToHome) // 'result' is of type Either<CommonMainFailure, Unit> | |
} |