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

Use UITableView reconfigureRows and UICollectionView reconfigureItems #159

Closed
wants to merge 1 commit into from

Conversation

laevandus
Copy link

@laevandus laevandus commented Feb 2, 2024

Use UITableView reconfigureRows and UICollectionView reconfigureItems starting from iOS 15 and tvOS 15. Increases performance since cells are not recreated and reduces UI glitches when there are multiple consecutive updates to the same cell. Sometimes we still would like to reload so there is a separate closure for making that decision.

Checklist

Description

Since iOS and tvOS 15 there are new reconfigureRows and reconfigureItems methods which do not trigger cell recreation. Gives better performance since cells are just updated, not recreated from scratch. Also useful since when there are multiple updates to the same index path, we do not run the reload cell animation.

Related Issue

Resolves issue 158

Motivation and Context

  • Better performance and more pleasing UI updates

Impact on Existing Code

  • Instead of full cell reload, now we reconfigure existing cells on ChangeSet.elementUpdated

@laevandus laevandus force-pushed the uikit-reconfigure-cells branch 2 times, most recently from c8fee58 to edf8e75 Compare February 6, 2024 08:31
Sources/Extensions/UIKitExtension.swift Outdated Show resolved Hide resolved
Sources/Extensions/UIKitExtension.swift Outdated Show resolved Hide resolved
Sources/Extensions/UIKitExtension.swift Outdated Show resolved Hide resolved
@laevandus laevandus force-pushed the uikit-reconfigure-cells branch 3 times, most recently from d0db972 to 179057a Compare February 6, 2024 19:22
… starting from iOS 15 and tvOS 15. Increases performance since cells are not recreated and reduces UI glitches when there are multiple consecutive updates to the same cell
@ra1028
Copy link
Owner

ra1028 commented Feb 16, 2024

Hi,
I'm not really familiar with the new API BUT I think it's not a complete replacement of reloadItems because it doen't cover some cases like the tableView needs to recreate the cells in case the data source returns another cell type/instance under conditions.

See also: https://developer.apple.com/documentation/uikit/uicollectionview/3801889-reconfigureitems

It improves performance under certain conditions, but may not be suitable as an official extension to DifferenceKit, as it doesn't cover all common cases.
I don't say this library is in maintenance mode completely but I'm not planning any breaking changes in the future, so I recommend that you set up a custom extension for your project.

@laevandus
Copy link
Author

laevandus commented Feb 16, 2024 via email

@ra1028 ra1028 closed this Feb 26, 2024
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

Successfully merging this pull request may close these issues.

3 participants