Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composable Diff improvements #43

Open
terekhovyes opened this issue Aug 9, 2020 · 1 comment
Open

Composable Diff improvements #43

terekhovyes opened this issue Aug 9, 2020 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed reddit Feedbacks from Reddit up-for-grabs Up For Grabs

Comments

@terekhovyes
Copy link

#40 added syntax to define Diff callback for whole adapter. But you still have no ability to define diff callback for register blocks separately.

There is example of how it may look like:

adapterOf<Animal> {
    register(
        layoutResource = R.layout.item_cat,
        viewHolder = ::CatHolder,
        diff = diff(
            areItemsTheSame = { cat1, cat2 -> cat1.name == cat2.name }
        )
    )

    register(
        layoutResource = R.layout.item_dog,
        viewHolder = ::DogHolder,
        diff = diff(
            areItemsTheSame = { dog1, dog2 -> dog1.bark == dog2.bark }
        )
    )
}

This builder under the hood should create single DiffUtil.Callback with multiple "delegates": one for Cat, one for Dog. Then, when DiffUtil.Callback methods are called, that Callback must pick appropriate "delegate" and call it

@ibrahimyilmaz ibrahimyilmaz added enhancement New feature or request reddit Feedbacks from Reddit good first issue Good for newcomers help wanted Extra attention is needed labels Aug 9, 2020
@ibrahimyilmaz ibrahimyilmaz added the up-for-grabs Up For Grabs label Aug 16, 2020
@JonibekXolmonov
Copy link

JonibekXolmonov commented Apr 4, 2024

Hi sir, is this optimisation still active. May I try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed reddit Feedbacks from Reddit up-for-grabs Up For Grabs
Projects
None yet
Development

No branches or pull requests

3 participants