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

Add support for DiffUtils #83

Open
sockeqwe opened this issue Mar 10, 2020 · 0 comments
Open

Add support for DiffUtils #83

sockeqwe opened this issue Mar 10, 2020 · 0 comments

Comments

@sockeqwe
Copy link
Owner

sockeqwe commented Mar 10, 2020

We could leverage the power of kotlin DSL even more to add support for DiffUtils. Something like that:

fun catAdapterDelegate() = adapterDelegate<Cat, Animal>(R.layout.item_cat) {

    val name : TextView = findViewById(R.id.name)
   
    bind { diffPayloads -> // diffPayloads is a List<Any> containing the Payload from your DiffUtils
        name.text = item.name // Item is of type Cat and is the current bound item.
    }

   diff {
      itemsTheSame { old, new -> old == new }   // returns true if they are the same
      contentTheSame {
         same { old, new -> false }             // returns true if content is the same
         changePayload { old, new -> ... }      // returns the payload
      }
   }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant