Comments (3)
Hi @plm75 ,
yeah, I agree. We need helpful feedback from people to understand how to best present this. Could you provide a list of questions you would like to be answered so we can write up some kind of FAQ?
from rxdatasources.
Hi @kzaher ,
Following up on your suggestion, the following is a quick and dirty list that summarizes what I currently understand of RxDataSources after literally only a few hours of playing with the examples and questions that I currently have.
Again, I've just started learning Rx so I may/probably have missed some obvious stuff so apologies in advance. Hope you or someone else will find time to review it and provide guidance for the questions.
-
How to implement dataSources the 'default' way without RxDataSources:
Four methods are available:
rx_itemsWithCellIdentifier(:String)
rx_itemsWithCellIdentifier(:String:Cell.Type)
rx_itemsWithCellFactory(:ObservableType)
rx_itemsWithDataSource(:protocol<RxTableViewDataSourceType, UITableViewDataSource>)
simplest example:
let dataSource = Observable<[String]>.just(["first", "second", "third"]) dataSource.bindTo(tableView.rx_itemsWithCellIdentifier("Cell")) { index, model, cell in cell.textLabel?.text = model } .addDisposableTo(disposeBag)
[ Question:
examples of when and how to use the other methods (withCellFactory, withDataSource)?
] -
Why use RxDataSources vs default method ?
The default method deals with very simple use cases.
RxDataSources are required when the data is structured into different sections with potentially different item types.
RxDataSources are required to perform animations on insert/modify/delete[ Question: is the above correct ? What did I miss ?]
-
How to use RxDataSources [no animations]
1- Define a struct that conforms to theSectionModelType
protocol (MySection)- Define
Item
, the type of items that the section will contain - Declare
items
property as an array ofItem
elements
2- Create a dataSource object as an instance of either:
-
RxCollectionViewSectionedReloadDataSource
-
RxTableViewSectionedReloadDataSource
and pass it MySection as generic type
3- customize closures on the dataSource as needed:
configureCell
titleForHeaderInSection
titleForFooterInSection
- etc
4- Define actual data as an Observable stream of MySection objects
5- Bind actual data to tableView with
rx_itemsWithDataSource(dataSource)
6- If needed, set delegate with `tableView.rx_setDelegate(self)``
[ Question: is the above correct ? What did I miss ?]
- Define
-
How to use RxDataSources [with animations]
Same as static sections, except MySection needs to conform toAnimatableSectionModelType
and dataSource object needs to be an instance of either:- RxCollectionViewSectionedAnimatedDataSource
- RxTableViewSectionedAnimatedDataSource
[ Question: is the above correct ? What did I miss ?]
from rxdatasources.
Hi @plm75 ,
everything you've said is correct.
rx_itemsWithCellIdentifier(:String)
rx_itemsWithCellIdentifier(:String:Cell.Type)
rx_itemsWithCellFactory(:ObservableType)
... are just conveniences for rx_itemsWithDataSource(:protocol<RxTableViewDataSourceType, UITableViewDataSource>)
I think we can improve the docs in both the main repo and this repo. Feel free to create a PR with that FAQ, or I'll create it in a couple of days.
from rxdatasources.
Related Issues (20)
- Issues that result in two section header
- RxTableViewSectionedAnimatedDataSource dataSource sectionModels are always same with newSections HOT 2
- [Carthage] IPHONEOS_DEPLOYMENT_TARGET on Xcode project does not match the SPM target. HOT 1
- RxDataSources collapses HOT 1
- Different version in .podspec from release tag HOT 3
- Reload all but one section
- RxDataSources not supported swift version 5.5.2 HOT 2
- Binding multiple data and cells in RxSwiftDataSource (attempt to insert section 0 but there are only 0 sections after the update)
- .github/workflows/swift.yml HOT 1
- Package.swift HOT 1
- dotnet new console --name OctocatApp
- RxCollectionViewSectionedAnimatedDataSource crash if estimatedItemSize was set in iOS 14.0&14.0.1
- Lack of support UICollectionView delegate method `contextMenuConfigurationForItemAt`or `contextMenuConfigurationForItemsAt`
- IdentifiableType with Unidirectional Data Flow HOT 2
- Question about items function parameters
- Altstore
- CHANGELOG doesn't seem to show you have a 5.0.0 release?
- About customizing row height for RxPickerViewViewAdapter.
- textView in tableView cell
- Privacy Manifest HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxdatasources.