codelab-kotlin-coroutines icon indicating copy to clipboard operation
codelab-kotlin-coroutines copied to clipboard

Advanced coroutines - applySort is called twice

Open dmihailov opened this issue 2 years ago • 0 comments
trafficstars

In the list with PLANTS, when filter button is pressed emitting of new live data and sorting is executed more than once. I added logging to be more clear:

In List<Plant>.applySort: println("Name: ${plant.name}, position: $positionForItem")

And in val plants: LiveData<List<Plant>> = liveData<List<Plant>> { ... println("Plant list: ${System.identityHashCode(plantList)}")

And this is observed in Logcat:

image

Same is observed when the filter is press again, but log is much bigger as all plants are shown.

How can this be optimized?

dmihailov avatar Jul 25 '23 06:07 dmihailov