为UITableView
和UICollectionView
提供类似React的API
ReactiveLists
为UITableView
和UICollectionView
提供类似React的API,这使得编写生成用户界面的无状态代码变得容易。
根据我们的经验,这可以使UI代码的可读性和可维护性显著提高。您不需要将内容的定义分散在多种数据源方法中,而可以简洁地定义内容。通过扫描源代码即可立即了解表格或集合的内容和布局。
您可以在我们的官方博客文章中了解更多关于这个库的来历。
特性
- 为
UITableView
和UICollectionView
提供类似React的声明式API - 模型更改时自动更新UI
示例
// Given a view controller with a table view
// 1. create cell models
let cell0 = ExampleTableCellModel(...)
let cell1 = ExampleTableCellModel(...)
let cell2 = ExampleTableCellModel(...)
// 2. create section models
let section0 = ExampleTableSectionViewModel(cellViewModels: [cell0, cell1, cell2])
// 3. create table model
let tableModel = TableViewModel(sectionModels: [section0])
// 4. create driver
self.driver = TableViewDriver(tableView: self.tableView, tableViewModel: tableModel)
// 5. update driver with new table model as it changes
let updatedTableModel = self.doSomethingToChangeModels()
self.driver.tableViewModel = updatedTableModel
// self.tableView will update automatically
项目状态
自2015年底以来,早期版本的UITableView
支持已包含在PlanGrid应用程序中,并且现在在应用程序的广泛部分中使用。由于我们只在极少数地方使用了UICollectionView
,因此对UICollectionView
的支持相对成熟。
特性 | 状态 |
---|---|
UITableView 支持 |
|
UICollectionView 支持 |
视觉
有关长期目标和方向,请参阅 VISION.md
。
开始使用
阅读我们的 开始使用指南,了解如何使用 ReactiveLists
。
文档
在此处阅读我们的 文档。由 jazzy 生成。由 GitHub Pages 托管。
生成文档
$ ./scripts/gen_docs.sh
需求
- Xcode 10.2+
- Swift 4.2 或 5.0
- iOS 11+
安装
CocoaPods(推荐)
use_frameworks!
# For latest release in CocoaPods
pod 'ReactiveLists'
# Latest on master branch
pod 'ReactiveLists', :git => 'https://github.com/plangrid/ReactiveLists.git', :branch => 'master'
贡献
授权协议
ReactiveLists
遵循MIT 许可协议。请参阅LICENSE
文件以获取详细信息。
版权所有 © 2018-present PlanGrid, Inc.