@@ -26,15 +26,15 @@ Writing table and collection view data sources is tedious. There is a large numb
26
26
RxSwift helps alleviate some of the burden with a simple data binding mechanism:
27
27
1 ) Turn your data into an Observable sequence
28
28
2 ) Bind the data to the tableView/collectionView using one of:
29
- - ` rx_items (dataSource:protocol<RxTableViewDataSourceType, UITableViewDataSource>)`
30
- - ` rx_items (cellIdentifier:String)`
31
- - ` rx_items (cellIdentifier:String:Cell.Type:_:)`
32
- - ` rx_items (_:_:)`
29
+ - ` rx.items (dataSource:protocol<RxTableViewDataSourceType, UITableViewDataSource>)`
30
+ - ` rx.items (cellIdentifier:String)`
31
+ - ` rx.items (cellIdentifier:String:Cell.Type:_:)`
32
+ - ` rx.items (_:_:)`
33
33
34
34
``` swift
35
- let dataSource = Observable< [String ]> .just ([" first element" , " second element" , " third element" ])
35
+ let data = Observable< [String ]> .just ([" first element" , " second element" , " third element" ])
36
36
37
- dataSource .bindTo (tableView.rx .items (cellIdentifier : " Cell" )) { index, model, cell in
37
+ data .bindTo (tableView.rx .items (cellIdentifier : " Cell" )) { index, model, cell in
38
38
cell.textLabel ? .text = model
39
39
}
40
40
.addDisposableTo (disposeBag)
@@ -47,7 +47,8 @@ These are precisely the use cases that RxDataSources helps solve.
47
47
With RxDataSources, it is super easy to just write
48
48
49
49
``` swift
50
- Observable.just ([MySection (header : " title" , items : [1 , 2 , 3 ])])
50
+ let dataSource = RxTableViewSectionedReloadDataSource< SectionModel< String , Int >> ()
51
+ Observable.just ([SectionModel (model : " title" , items : [1 , 2 , 3 ])])
51
52
.bindTo (tableView.rx .items (dataSource : dataSource))
52
53
.addDisposableTo (disposeBag)
53
54
```
@@ -95,7 +96,7 @@ let dataSource = RxTableViewSectionedReloadDataSource<SectionOfCustomData>()
95
96
96
97
``` swift
97
98
dataSource.configureCell = { ds, tv, ip, item in
98
- let cell = tv.dequeueReusableCellWithIdentifier ( " Cell" , forIndexPath : ip)
99
+ let cell = tv.dequeueReusableCell ( withIdentifier : " Cell" , for : ip)
99
100
cell.textLabel ? .text = " Item \( item.anInt ) : \( item.aString ) - \( item.aCGPoint .x ) :\( item.aCGPoint .y ) "
100
101
return cell
101
102
}
0 commit comments