android / codelab-kotlin-coroutines

Kotlin Coroutines codelab
Apache License 2.0
552 stars 268 forks source link

Spinner never stops running in final version code #72

Closed rafipanoyan closed 4 years ago

rafipanoyan commented 4 years ago

Inside the "Learn advanced coroutines with Kotlin Flow and LiveData" codelab, section 14, the spinner is supposed to stop by calling

.onCompletion {  _spinner.value = false }

In fact it never stops since onCompletion is supposed to run after the flow is completed, and not supposed to run after each new value inside the channel.

You can test that by running the finished_code module after removing the lines 133 and 147 of PlantListViewModel. The comments above say that they must be removed after the Flow refact but they are still there.

rafipanoyan commented 4 years ago

IMO the spinner state should be updated to false inside the mapLatest lambda, just as the _spinner.value = true

rafipanoyan commented 4 years ago

It's a duplicate of #60 , closing it now