jflinter / Dwifft

Swift Diff
MIT License
1.86k stars 147 forks source link

Support for reload instead of delete+insert #60

Open NinoScript opened 7 years ago

NinoScript commented 7 years ago

I'm exploring using a different animation for reloading a row, for that I would need Dwifft to call reloadItems instead of deleteItems and insertItems.

My first guess is that a adding a naive support for reloads would just require checking for the intersection between deletes and inserts in processChanges(newState:diff:).

What do you think?

larryonoff commented 6 years ago

It maybe reasonable implementing a diffable.diffIdentifier similar like IGListKit. So the library is able to understand that it's the same object, but needs reload.

alessandro-martin commented 6 years ago

I think that the best solution is for the API's user to change the way she calculates the sectioned values so a change to the details of an item are reflected and treated as a deletion + insertion.

r00li commented 5 years ago

I have a problem with this as well. Here is a use case example....

I have cells that include some time interval display (something like: "updated x seconds ago") and a button/tag that can be toggled in other parts of the app as well.

When the user uses pull to refresh the new content is loaded and tableview is updated using calculator.sectionedValues = x. The cells that are added or removed update and animate as they should. The issue is with the cells that haven't changed. So either their data model has stayed completely identical (that "updated x seconds ago") or one of their tags changed but the rest of the content didn't. I would want the cells to be reloaded even though they haven't really changed. The data model here can be completely identical, but I still need the cells to be reloaded.