[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7012":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":16,"stars30d":17,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":18,"rankGlobal":10,"rankLanguage":10,"license":19,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":36,"lastSyncTime":37,"discoverSource":38},7012,"RxDataSources","RxSwiftCommunity\u002FRxDataSources","RxSwiftCommunity","UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)","",null,"Swift",3100,495,63,81,0,1,30.09,"MIT License",false,"main",true,[24,25,26,27,28,29,30,31,32],"animation","binding","collectionview","datasource","diff","rxswift","sections","tableview","unidirectional","2026-06-12 02:01:33","[![Travis CI](https:\u002F\u002Ftravis-ci.org\u002FRxSwiftCommunity\u002FRxDataSources.svg?branch=main)](https:\u002F\u002Ftravis-ci.org\u002FRxSwiftCommunity\u002FRxDataSources)\n\nTable and Collection view data sources\n======================================\n\n## Features\n\n- [x] **O(N)** algorithm for calculating differences\n  - the algorithm has the assumption that all sections and items are unique so there is no ambiguity\n  - in case there is ambiguity, fallbacks automagically on non animated refresh\n- [x] it applies additional heuristics to send the least number of commands to sectioned view\n  - even though the running time is linear, preferred number of sent commands is usually a lot less than linear\n  - it is preferred (and possible) to cap the number of changes to some small number, and in case the number of changes grows towards linear, just do normal reload\n- [x] Supports **extending your item and section structures**\n  - just extend your item with `IdentifiableType` and `Equatable`, and your section with `AnimatableSectionModelType`\n- [x] Supports all combinations of two level hierarchical animations for **both sections and items**\n  - Section animations: Insert, Delete, Move\n  - Item animations: Insert, Delete, Move, Reload (if old value is not equal to new value)\n- [x] Configurable animation types for `Insert`, `Reload` and `Delete` (Automatic, Fade, ...)\n- [x] Example app\n- [x] Randomized stress tests (example app)\n- [x] Supports editing out of the box (example app)\n- [x] Works with `UITableView` and `UICollectionView`\n\n## Why\nWriting table and collection view data sources is tedious. There is a large number of delegate methods that need to be implemented for the simplest case possible.\n\nRxSwift helps alleviate some of the burden with a simple data binding mechanism:\n1) Turn your data into an Observable sequence\n2) Bind the data to the tableView\u002FcollectionView using one of:\n  - `rx.items(dataSource:protocol\u003CRxTableViewDataSourceType, UITableViewDataSource>)`\n  - `rx.items(cellIdentifier:String)`\n  - `rx.items(cellIdentifier:String:Cell.Type:_:)`\n  - `rx.items(_:_:)`\n\n```swift\nlet data = Observable\u003C[String]>.just([\"first element\", \"second element\", \"third element\"])\n\ndata.bind(to: tableView.rx.items(cellIdentifier: \"Cell\")) { index, model, cell in\n  cell.textLabel?.text = model\n}\n.disposed(by: disposeBag)\n```\n\nThis works well with simple data sets but does not handle cases where you need to bind complex data sets with multiples sections, or when you need to perform animations when adding\u002Fmodifying\u002Fdeleting items.  \n\nThese are precisely the use cases that RxDataSources helps solve.\n\nWith RxDataSources, it is super easy to just write\n\n```swift\nlet dataSource = RxTableViewSectionedReloadDataSource\u003CSectionModel\u003CString, Int>>(configureCell: configureCell)\nObservable.just([SectionModel(model: \"title\", items: [1, 2, 3])])\n    .bind(to: tableView.rx.items(dataSource: dataSource))\n    .disposed(by: disposeBag)\n```\n![RxDataSources example app](https:\u002F\u002Fraw.githubusercontent.com\u002Fkzaher\u002Frxswiftcontent\u002Frxdatasources\u002FRxDataSources.gif)\n\n## How\nGiven the following custom data structure:\n```swift\nstruct CustomData {\n  var anInt: Int\n  var aString: String\n  var aCGPoint: CGPoint\n}\n```\n\n1) Start by defining your sections with a struct that conforms to the `SectionModelType` protocol:\n  - define the `Item` typealias: equal to the type of items that the section will contain\n  - declare an `items` property: of type array of `Item`\n\n```swift\nstruct SectionOfCustomData {\n  var header: String    \n  var items: [Item]\n}\nextension SectionOfCustomData: SectionModelType {\n  typealias Item = CustomData\n\n   init(original: SectionOfCustomData, items: [Item]) {\n    self = original\n    self.items = items\n  }\n}\n```\n\n2) Create a dataSource object and pass it your `SectionOfCustomData` type:\n```swift\nlet dataSource = RxTableViewSectionedReloadDataSource\u003CSectionOfCustomData>(\n  configureCell: { dataSource, tableView, indexPath, item in\n    let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\", for: indexPath)\n    cell.textLabel?.text = \"Item \\(item.anInt): \\(item.aString) - \\(item.aCGPoint.x):\\(item.aCGPoint.y)\"\n    return cell\n})\n```\n\n3) Customize closures on the dataSource as needed:\n- `titleForHeaderInSection`\n- `titleForFooterInSection`\n- etc\n\n```swift\ndataSource.titleForHeaderInSection = { dataSource, index in\n  return dataSource.sectionModels[index].header\n}\n\ndataSource.titleForFooterInSection = { dataSource, index in\n  return dataSource.sectionModels[index].footer\n}\n\ndataSource.canEditRowAtIndexPath = { dataSource, indexPath in\n  return true\n}\n\ndataSource.canMoveRowAtIndexPath = { dataSource, indexPath in\n  return true\n}\n```\n\n4) Define the actual data as an Observable sequence of CustomData objects and bind it to the tableView\n```swift\nlet sections = [\n  SectionOfCustomData(header: \"First section\", items: [CustomData(anInt: 0, aString: \"zero\", aCGPoint: CGPoint.zero), CustomData(anInt: 1, aString: \"one\", aCGPoint: CGPoint(x: 1, y: 1)) ]),\n  SectionOfCustomData(header: \"Second section\", items: [CustomData(anInt: 2, aString: \"two\", aCGPoint: CGPoint(x: 2, y: 2)), CustomData(anInt: 3, aString: \"three\", aCGPoint: CGPoint(x: 3, y: 3)) ])\n]\n\nObservable.just(sections)\n  .bind(to: tableView.rx.items(dataSource: dataSource))\n  .disposed(by: disposeBag)\n```\n\n### Animated Data Sources\n\nRxDataSources provides two special data source types that automatically take care of animating changes in the bound data source: `RxTableViewSectionedAnimatedDataSource` and `RxCollectionViewSectionedAnimatedDataSource`.\n\nTo use one of the two animated data sources, you must take a few extra steps on top of those outlined above:\n\n- SectionOfCustomData needs to conform to `AnimatableSectionModelType`\n- Your data model must conform to\n  * `IdentifiableType`: The `identity` provided by the `IdentifiableType` protocol must be an **immutable identifier representing an instance of the model**. For example, in case of a `Car` model, you might want to use the car's `plateNumber` as its identity.\n  * `Equatable`: Conforming to `Equatable` helps `RxDataSources` determine which cells have changed so it can animate only these specific cells. Meaning, changing **any** of the `Car` model's properties will trigger an animated reload of that cell.\n\n## Requirements\n\nXcode 10.2\n\nSwift 5.0\n\nFor Swift 4.x version please use versions `3.0.0 ... 3.1.0`\nFor Swift 3.x version please use versions `1.0 ... 2.0.2`\nFor Swift 2.3 version please use versions `0.1 ... 0.9`\n\n## Installation\n\n**We'll try to keep the API as stable as possible, but breaking API changes can occur.**\n\n### CocoaPods\n\nPodfile\n```\npod 'RxDataSources', '~> 5.0'\n```\n\n### Carthage\n\nCartfile\n```\ngithub \"RxSwiftCommunity\u002FRxDataSources\" ~> 5.0\n```\n\n### Swift Package Manager\n\nCreate a `Package.swift` file.\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n    name: \"SampleProject\",\n    dependencies: [\n        .package(url: \"https:\u002F\u002Fgithub.com\u002FRxSwiftCommunity\u002FRxDataSources.git\", from: \"5.0.0\")\n    ]\n)\n```\n\nIf you are using Xcode 11 or higher, go to **File \u002F Swift Packages \u002F Add Package Dependency...** and enter package repository URL **https:\u002F\u002Fgithub.com\u002FRxSwiftCommunity\u002FRxDataSources.git**, then follow the instructions.\n","RxDataSources 是一个用于 RxSwift 的 UITableView 和 UICollectionView 数据源库，支持分段、动画更新和编辑等功能。其核心功能包括高效的O(N)差异计算算法，最小化发送给视图的命令数量，以及对复杂数据结构的支持，如可扩展的项目和节模型。此外，它还支持多种动画类型，并且能够处理多层级的数据动画。该库适用于需要展示复杂列表或集合视图的应用场景，特别是当这些视图需要频繁更新或包含多个部分时。通过简化数据绑定过程，RxDataSources 显著减少了开发者在实现数据源相关逻辑时的工作量。",2,"2026-06-11 03:10:07","top_language"]