Skip to content
This repository was archived by the owner on Aug 16, 2023. It is now read-only.
This repository was archived by the owner on Aug 16, 2023. It is now read-only.

Advanced coroutines - applySort is called twice #184

Open
@dmihailov

Description

@dmihailov

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.applySort:
println("Name: ${plant.name}, position: $positionForItem")

And in
val plants: LiveData<List> = liveData<List> { ...
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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions