ReactiveDataDisplayManager
ReactiveDataDisplayManager copied to clipboard
ReactiveDataDisplayManager
It is the whole approach to working with scrollable lists or collections.
About
This Framework was made to speed up development of scrollable collections like UITableView or UICollectionView, and to provide new way to easy extend collections functionality.
Breaking changes
We made a massive refactoring with version 7.0.0. Please read our migration guide if you were using version 6 or older.
Currently supported features
- Populating cells without implementing delegate and datasource by yourself
- Inserting, replacing or removing cells without reload
- Expanding and collapsing cells inside collection
- Moving or Drag'n'Drop cells inside collection
- Customizing of section headers and index titles
Usage
Step by step example of configuring simple list of labels.
Prepare cell
You can layout your cell from xib or from code. It doesn't matter.
Just extend your cell to ConfigurableItem
to fill subviews with model, when cell will be created.
import ReactiveDataDisplayManager
final class LabelCell: UITableViewCell {
// MARK: - IBOutlets
@IBOutlet private weak var titleLabel: UILabel!
}
// MARK: - ConfigurableItem
extension LabelCell: ConfigurableItem {
typealias Model = String
func configure(with model: Model) {
titleLabel.text = model
}
}
Prepare collection
Just call rddm
from collection
- add plugins for your needs
- build your ReactiveDataDisplayManager
final class ExampleTableController: UIViewController {
// MARK: - IBOutlets
@IBOutlet private weak var tableView: UITableView!
// MARK: - Private Properties
private lazy var ddm = tableView.rddm.baseBuilder
.add(plugin: .selectable())
.build()
// MARK: - UIViewController
override func viewDidLoad() {
super.viewDidLoad()
fill()
}
}
Fill collection
Convert models to generators and call ddm => .reload
private extension MainTableViewController {
func fill() {
let models = ["First", "Second", "Third"]
for model in models {
let generator = TitleTableViewCell.rddm.baseGenerator(with: model)
generator.didSelectEvent += { [weak self] in
// do some logic
}
// Add generator to adapter
ddm.addCellGenerator(generator)
// or simple use operator `+=`
ddm += generator
}
ddm => .reload
}
}
Enjoy
As you can see, you don't need to conform UITableViewDelegate
and UITableViewDataSource
. This protocols are hidden inside ReactiveDataDisplayManager.
You can extend table functionality with adding plugins and replacing generator.
You can check more examples in our example project or in full documentation. Small cheat sheet table could also be usefull.
Installation
Just add ReactiveDataDisplayManager to your Podfile
like this
pod 'ReactiveDataDisplayManager' ~> 7.3
Changelog
All notable changes to this project will be documented in this file.
Issues
For issues, file directly in the main ReactiveDataDisplayManager repo.
Contribute
If you would like to contribute to the package (e.g. by improving the documentation, solving a bug or adding a cool new feature), please review our contribution guide first and send us your pull request.
You PRs are always welcome.
License
MIT License