Skip to content

Commit bd92a73

Browse files
Simplify UseCase#7
1 parent c3dbd59 commit bd92a73

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

app/src/main/java/com/lukaslechner/coroutineusecasesonandroid/usecases/coroutines/usecase7/TimeoutAndRetryViewModel.kt

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@ class TimeoutAndRetryViewModel(
1212

1313
fun performNetworkRequest() {
1414
uiState.value = UiState.Loading
15-
viewModelScope.launch {
16-
val numberOfRetries = 2
17-
val timeout = 1000L
15+
val numberOfRetries = 2
16+
val timeout = 1000L
1817

19-
try {
20-
val oreoVersionsDeferred = async {
21-
retryWithTimeout(numberOfRetries, timeout) {
22-
api.getAndroidVersionFeatures(27)
23-
}
24-
}
18+
val oreoVersionsDeferred = viewModelScope.async {
19+
retryWithTimeout(numberOfRetries, timeout) {
20+
api.getAndroidVersionFeatures(27)
21+
}
22+
}
2523

26-
val pieVersionsDeferred = async {
27-
retryWithTimeout(numberOfRetries, timeout) {
28-
api.getAndroidVersionFeatures(28)
29-
}
30-
}
24+
val pieVersionsDeferred = viewModelScope.async {
25+
retryWithTimeout(numberOfRetries, timeout) {
26+
api.getAndroidVersionFeatures(28)
27+
}
28+
}
3129

30+
viewModelScope.launch {
31+
try {
3232
val versionFeatures = listOf(
3333
oreoVersionsDeferred,
3434
pieVersionsDeferred

0 commit comments

Comments
 (0)