-
Notifications
You must be signed in to change notification settings - Fork 22
Single network request
Devrath edited this page Jun 15, 2021
·
1 revision
class PerformSingleNetworkRequestViewModel(
private val mockApi: MockApi = mockApi()
) : BaseViewModel<UiState>() {
fun performSingleNetworkRequest() {
uiState.value = UiState.Loading
viewModelScope.launch {
try {
val recentAndroidVersions = mockApi.getRecentAndroidVersions()
uiState.value = UiState.Success(recentAndroidVersions)
} catch (exception: Exception) {
Timber.e(exception)
uiState.value = UiState.Error("Network Request failed!")
}
}
}
}