Skip to content

Commit

Permalink
Update task.md
Browse files Browse the repository at this point in the history
language checked
  • Loading branch information
stephen-hero authored and kochaika committed Dec 12, 2023
1 parent dc5f7f9 commit 4a13c59
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Coroutines/Showing progress/task.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Despite the information for some repositories being loaded rather quickly, the user only sees the resulting list after all of
the data has been loaded. Until then, the loader icon runs showing the progress, but there's no information about the current
state or what contributors are already loaded.
Despite the information for some repositories being loaded quite quickly, the user only sees the resulting list after all
the data has been loaded. Until then, the loader icon progresses, showing no information about the current
state or which contributors have already been loaded.

You can show the intermediate results earlier and display all of the contributors after loading the data for each of the
repositories:
You can present the intermediate results sooner and display all of the contributors after loading the data for each
repository:

![Loading data](images/loading.gif)

To implement this functionality, in the [src/tasks/Request6Progress.kt](course://Coroutines/Showing progress/src/tasks/Request6Progress.kt), you'll need to pass the logic updating the UI
as a callback, so that it's called on each intermediate state:
as a callback, so that it's called at each intermediate state:

```kotlin
suspend fun loadContributorsProgress(
Expand Down Expand Up @@ -36,18 +36,18 @@ launch(Dispatchers.Default) {

* The `updateResults()` parameter is declared as `suspend` in `loadContributorsProgress()`. It's necessary to call
`withContext`, which is a `suspend` function inside the corresponding lambda argument.
* `updateResults()` callback takes an additional Boolean parameter as an argument specifying whether the loading has
* The `updateResults()` callback takes an additional Boolean parameter as an argument, specifying whether the loading has
completed and the results are final.

## Task

In the [src/tasks/Request6Progress.kt](course://Coroutines/Showing progress/src/tasks/Request6Progress.kt) file, implement the `loadContributorsProgress()` function that shows the intermediate
progress. Base it on the `loadContributorsSuspend()` function from [src/tasks/Request4Suspend.kt](course://Coroutines/Showing progress/src/tasks/Request4Suspend.kt).
In the [src/tasks/Request6Progress.kt](course://Coroutines/Showing progress/src/tasks/Request6Progress.kt) file, implement the `loadContributorsProgress()` function, which displays the intermediate
progress. This should be based on the `loadContributorsSuspend()` function from [src/tasks/Request4Suspend.kt](course://Coroutines/Showing progress/src/tasks/Request4Suspend.kt).

* Use a simple version without concurrency; you'll add it later in the next section.
* The intermediate list of contributors should be shown in an "aggregated" state, not just the list of users loaded for
each repository.
* The total number of contributions for each user should be increased when the data for each new
* The total number of contributions for each user should increment every time data for a new
repository is loaded.

For a more detailed description, you can look at [this article](https://kotlinlang.org/docs/coroutines-and-channels.html#showing-progress)
For a more detailed description, you can refer to [this article](https://kotlinlang.org/docs/coroutines-and-channels.html#showing-progress)

0 comments on commit 4a13c59

Please sign in to comment.