{"id":2888,"url":"https://github.com/ra1028/DiffableDataSources","last_synced_at":"2025-08-06T16:31:39.596Z","repository":{"id":34979349,"uuid":"192011512","full_name":"ra1028/DiffableDataSources","owner":"ra1028","description":"💾 A library for backporting UITableView/UICollectionViewDiffableDataSource.","archived":false,"fork":false,"pushed_at":"2023-04-11T23:18:42.000Z","size":4317,"stargazers_count":854,"open_issues_count":19,"forks_count":70,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-08T08:05:31.104Z","etag":null,"topics":["algorithm","collectionview","datasource","diff","diffable","diffing","tableview","wwdc19"],"latest_commit_sha":null,"homepage":"https://ra1028.github.io/DiffableDataSources","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ra1028.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-06-14T22:19:57.000Z","updated_at":"2024-11-28T06:21:34.000Z","dependencies_parsed_at":"2022-08-08T03:15:25.406Z","dependency_job_id":"e809f41f-c3ff-48fc-bd82-17c210c7cef3","html_url":"https://github.com/ra1028/DiffableDataSources","commit_stats":{"total_commits":30,"total_committers":12,"mean_commits":2.5,"dds":0.5333333333333333,"last_synced_commit":"a457cf63456b3aeec2a3626af0230c98b0733927"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FDiffableDataSources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FDiffableDataSources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FDiffableDataSources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ra1028%2FDiffableDataSources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ra1028","download_url":"https://codeload.github.com/ra1028/DiffableDataSources/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228703554,"owners_count":17959669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithm","collectionview","datasource","diff","diffable","diffing","tableview","wwdc19"],"created_at":"2024-01-05T20:16:25.500Z","updated_at":"2024-12-09T16:31:12.170Z","avatar_url":"https://github.com/ra1028.png","language":"Swift","readme":"\u003cH1 align=\"center\"\u003e\nDiffableDataSources\n\u003c/H1\u003e\n\u003cH4 align=\"center\"\u003e\n💾 A library for backporting UITableView/UICollectionViewDiffableDataSource\u003c/br\u003e\npowered by \u003ca href=\"https://github.com/ra1028/DifferenceKit\"\u003eDifferenceKit\u003c/a\u003e.\n\u003c/H4\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://developer.apple.com/swift\"\u003e\u003cimg alt=\"Swift5\" src=\"https://img.shields.io/badge/language-Swift5-orange.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ra1028/DiffableDataSources/releases/latest\"\u003e\u003cimg alt=\"Release\" src=\"https://img.shields.io/github/release/ra1028/DiffableDataSources.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://cocoapods.org/pods/DiffableDataSources\"\u003e\u003cimg alt=\"CocoaPods\" src=\"https://img.shields.io/cocoapods/v/DiffableDataSources.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/Carthage/Carthage\"\u003e\u003cimg alt=\"Carthage\" src=\"https://img.shields.io/badge/carthage-compatible-yellow.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://swift.org/package-manager\"\u003e\u003cimg alt=\"Swift Package Manager\" src=\"https://img.shields.io/badge/SwiftPM-compatible-yellowgreen.svg\"/\u003e\u003c/a\u003e\n\u003c/br\u003e\n\u003ca href=\"https://dev.azure.com/ra1028/GitHub/_build/latest?definitionId=3\u0026branchName=master\"\u003e\u003cimg alt=\"Build Status\" src=\"https://dev.azure.com/ra1028/GitHub/_apis/build/status/ra1028.DiffableDataSources?branchName=master\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://developer.apple.com/\"\u003e\u003cimg alt=\"Platform\" src=\"https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS-green.svg\"/\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/ra1028/DiffableDataSources/blob/master/LICENSE\"\u003e\u003cimg alt=\"Lincense\" src=\"https://img.shields.io/badge/License-Apache%202.0-black.svg\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nMade with ❤️ by \u003ca href=\"https://github.com/ra1028\"\u003eRyo Aoyama\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n## Introduction\n\n\u003cimg src=\"https://raw.githubusercontent.com/ra1028/DiffableDataSources/master/assets/insertion_sort.gif\" height=\"400\" align=\"right\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/ra1028/DiffableDataSources/master/assets/mountains.gif\" height=\"400\" align=\"right\"\u003e\n\nApple has announced a diffable data source at WWDC 2019.  \nIt's a great API that easily updating our table view and collection view items using automatic diffing.  \nHowever, it's a little while before we can use it in a production service.  \nThat because it requires the latest OS to use.  \nDiffableDataSources make it possible to introduce almost the same functionality from now on.  \n\nUses a sophisticated open source [DifferenceKit](https://github.com/ra1028/DifferenceKit) for the algorithm engine.  \nIt's extremely fast and completely avoids synchronization bugs, exceptions, and crashes.  \n\n\u003cbr clear=\"all\"\u003e\n\n---\n\n## Difference from the Official\n\n#### Spec\n\n- Supports iOS 9.0+ / macOS 10.11+ / tvOS 9.0+\n- Open sourced algorithm.\n- Duplicate sections or items are allowed.  \n- Using `performBatchUpdates` for diffing updates.\n\n#### Namings\n\n`DiffableDataSources` have different class names to avoid conflicts with the official API.  \nCorrespondence table is below.  \n\n|Official                                                                    |Backported                           |\n|:---------------------------------------------------------------------------|:------------------------------------|\n|[NSDiffableDataSourceSnapshot][NSDiffableDataSourceSnapshot_doc]            |DiffableDataSourceSnapshot           |\n|[UITableViewDiffableDataSource][UITableViewDiffableDataSource_doc]          |TableViewDiffableDataSource          |\n|[UICollectionViewDiffableDataSource][UICollectionViewDiffableDataSource_doc]|CollectionViewDiffableDataSource     |\n|[NSCollectionViewDiffableDataSource][NSCollectionViewDiffableDataSource_doc]|CocoaCollectionViewDiffableDataSource|\n\n[NSDiffableDataSourceSnapshot_doc]: https://developer.apple.com/documentation/uikit/uitableviewdiffabledatasource\n[UITableViewDiffableDataSource_doc]: https://developer.apple.com/documentation/uikit/uitableviewdiffabledatasource\n[UICollectionViewDiffableDataSource_doc]: https://developer.apple.com/documentation/uikit/uicollectionviewdiffabledatasource\n[NSCollectionViewDiffableDataSource_doc]: https://developer.apple.com/documentation/appkit/nscollectionviewdiffabledatasource\n\n---\n\n## Getting Started\n\n- [API Documentation](https://ra1028.github.io/DiffableDataSources)\n- [Example Apps](https://github.com/ra1028/DiffableDataSources/tree/master/Examples)\n- [WWDC 2019 Session](https://developer.apple.com/videos/play/wwdc2019/220)\n\n#### Build Project\n\n```sh\n$ git clone https://github.com/ra1028/DiffableDataSources.git\n$ cd DiffableDataSources/\n$ make setup\n$ open DiffableDataSources.xcworkspace\n```\n\n---\n\n## Basic Usage\n\nFirst, define the type representing section.  \nIt should conforms to `Hashable` for identifies from the all sections.  \nType of enum can used conveniently because it conforms `Hashable` by default.  \n\n```swift\nenum Section {\n    case main\n}\n```\n\nThen, define the item type conforms to `Hashable`.  \n\n```swift\nstruct User: Hashable {\n    var name: String\n}\n```\n\nCreate a data source object, it will be set to table view automatically.  \nYou should dequeue the non nil cells via closure.  \n\n```swift\nfinal class UsersViewController: UIViewController {\n    let tableView: UITableView = ...\n\n    lazy var dataSource = TableViewDiffableDataSource\u003cSection, User\u003e(tableView: tableView) { tableView, indexPath, user in\n        let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\", for: indexPath)\n        cell.textLabel?.text = user.name\n        return cell\n    }\n\n    override func viewDidLoad() {\n        super.viewDidLoad()\n\n        tableView.register(UITableViewCell.self, forCellReuseIdentifier: \"Cell\")\n    }\n}\n```\n\nManages and updates the data sources intuitively by intermediating `DiffableDataSourceSnapshot`.  \nThe UI isn't updated until you apply the edited snapshot object.  \nUpdate the UI with diffing animation automatically calculated by applying an edited snapshot.  \n\n```swift\nlet users = [\n    User(name: \"Steve Jobs\"),\n    User(name: \"Stephen Wozniak\"),\n    User(name: \"Tim Cook\"),\n    User(name: \"Jonathan Ive\")\n]\n\nlet snapshot = DiffableDataSourceSnapshot\u003cSection, User\u003e()\nsnapshot.appendSections([.main])\nsnapshot.appendItems(users)\n\ndataSource.apply(snapshot) {\n    // completion\n}\n```\n\nCheck the documentation for more detailed API.  \n\n\u003cH3 align=\"center\"\u003e\n\u003ca href=\"https://ra1028.github.io/DiffableDataSources\"\u003e[See More Usage]\u003c/a\u003e\n\u003c/H3\u003e\n\n---\n\n## Requirements\n\n- Swift 5.0+\n- iOS 9.0+\n- macOS 10.11+\n- tvOS 9.0+\n\n---\n\n## Installation\n\n### [CocoaPods](https://cocoapods.org)\nAdd the following to your `Podfile`:\n```ruby\npod 'DiffableDataSources'\n```\n\n### [Carthage](https://github.com/Carthage/Carthage)\nAdd the following to your `Cartfile`:\n```\ngithub \"ra1028/DiffableDataSources\"\n```\n\n### [Swift Package Manager](https://swift.org/package-manager/)\nAdd the following to the dependencies of your `Package.swift`:\n```swift\n.package(url: \"https://github.com/ra1028/DiffableDataSources.git\", from: \"x.x.x\")\n```\n\n---\n\n## Contributing\n\nPull requests, bug reports and feature requests are welcome 🚀  \nPlease see the [CONTRIBUTING](https://github.com/ra1028/DiffableDataSources/blob/master/CONTRIBUTING.md) file for learn how to contribute to DiffableDataSources.  \n\n---\n\n## Relations\n\n#### [DifferenceKit](https://github.com/ra1028/DifferenceKit)  \nA fast and flexible O(n) difference algorithm framework for Swift collection.\n\n#### [Carbon](https://github.com/ra1028/Carbon)  \nA declarative library for building component-based user interfaces in UITableView and UICollectionView.\n\n---\n\n## License\n\nDiffableDataSources is released under the [Apache 2.0 License](https://github.com/ra1028/DiffableDataSources/blob/master/LICENSE).  \n","funding_links":[],"categories":["UI","Libs","UI [🔝](#readme)","iOS","wwdc19","Swift"],"sub_categories":["Table View / Collection View","UI","DataSources"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fra1028%2FDiffableDataSources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fra1028%2FDiffableDataSources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fra1028%2FDiffableDataSources/lists"}