@@ -142,8 +142,8 @@ This API is used by the `loadContributorsBlocking()` function to fetch the list
142
142
* The final item on each line is the actual message: how many repositories or contributors were loaded.
143
143
144
144
This log output demonstrates that all the results were logged from the main thread. When you run the code with a _BLOCKING_
145
- option, the window freezes and don ' t react to input until the loading is finished. All the requests are executed from
146
- the same thread as the one called `loadContributorsBlocking()` from , which is the main UI thread (in Swing, it' s an AWT
145
+ option, the window freezes and doesn ' t react to input until the loading is finished. All the requests are executed from
146
+ the same thread as the one that called `loadContributorsBlocking()`, which is the main UI thread (in Swing, it' s an AWT
147
147
event dispatching thread). This main thread gets blocked, and that' s why the UI is frozen:
148
148
149
149
{width=700}
@@ -311,14 +311,14 @@ fun loadContributorsCallbacks(
311
311
val allUsers = mutableListOf<User >()
312
312
for (repo in repos) {
313
313
service.getRepoContributorsCall(req.org, repo.name)
314
- .onResponse { responseUsers ->
314
+ .onResponse { responseUsers -> // #2
315
315
logUsers(repo, responseUsers)
316
316
val users = responseUsers.bodyList()
317
317
allUsers + = users
318
318
}
319
319
}
320
320
}
321
- // TODO: Why this code doesn't work? How to fix that?
321
+ // TODO: Why doesn't this code work? How to fix that?
322
322
updateResults(allUsers.aggregate())
323
323
}
324
324
```
@@ -441,7 +441,7 @@ interface GitHubService {
441
441
```
442
442
443
443
* `getOrgRepos()` is defined as a `suspend` function. When you use a suspending function to perform a request, the
444
- underlying thread isn' t blocked. You ' ll find the details on how it works exactly later.
444
+ underlying thread isn' t blocked. You ' ll find the details on how it exactly works later.
445
445
* `getOrgRepos()` returns the result directly instead of returning a `Call`. If the result is unsuccessful, an
446
446
exception is thrown.
447
447
@@ -1546,4 +1546,4 @@ can see the difference in tests using virtual time.
1546
1546
## What' s next
1547
1547
1548
1548
* Check out the [Asynchronous Programming with Kotlin ](https: // kotlinconf.com/workshops/) workshop at KotlinConf.
1549
- * Find out more about using [virtual time and experimental testing package](https: // kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/).
1549
+ * Find out more about using [virtual time and experimental testing package](https: // kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-test/).
0 commit comments