Created
February 3, 2024 04:16
-
-
Save LloydBlv/9bad5a2240ffcba45e2062c0e9c55b94 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 PricesViewModel @Inject constructor( | |
errorFormatter: dagger.Lazy<ErrorFormatter>, | |
pricesUseCase: dagger.Lazy<GetPricesUseCase> | |
): ViewModel() { | |
val state = pricesUseCase.get().invoke() | |
.map { | |
State.Success(it) | |
} | |
.catch { | |
val error = errorFormatter.get().format(it) | |
emit(State.Error(error)) | |
}.stateInDefault(viewModelScope, State.Loading) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment