Skip to content

Commit ab5391a

Browse files
committed
Modernizes example app.
1 parent 56c20b3 commit ab5391a

5 files changed

+21
-21
lines changed

Example/Example1_CustomizationUsingTableViewDelegate.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ class CustomizationUsingTableViewDelegate : UIViewController {
6767
]
6868

6969
Observable.just(sections)
70-
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
70+
.bindTo(tableView.rx.items(dataSource: dataSource))
7171
.addDisposableTo(disposeBag)
7272

73-
tableView.rx_setDelegate(self)
73+
tableView.rx.setDelegate(self)
7474
.addDisposableTo(disposeBag)
7575

7676
self.dataSource = dataSource
@@ -83,7 +83,7 @@ extension CustomizationUsingTableViewDelegate : UITableViewDelegate {
8383
// you can also fetch item
8484
guard let item = dataSource?.itemAtIndexPath(indexPath),
8585
// .. or section and customize what you like
86-
_ = dataSource?.sectionAtIndex(indexPath.section)
86+
let _ = dataSource?.sectionAtIndex(indexPath.section)
8787
else {
8888
return 0.0
8989
}

Example/Example2_RandomizedSectionsAnimation.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ViewController: UIViewController {
3535
let initialRandomizedSections = Randomizer(rng: PseudoRandomGenerator(4, 3), sections: initialValue())
3636

3737
let ticks = Observable<Int>.interval(1, scheduler: MainScheduler.instance).map { _ in () }
38-
let randomSections = Observable.of(ticks, refreshButton.rx_tap.asObservable())
38+
let randomSections = Observable.of(ticks, refreshButton.rx.tap.asObservable())
3939
.merge()
4040
.scan(initialRandomizedSections) { a, _ in
4141
return a.randomize()
@@ -51,11 +51,11 @@ class ViewController: UIViewController {
5151
skinTableViewDataSource(reloadDataSource)
5252

5353
randomSections
54-
.bindTo(animatedTableView.rx_itemsWithDataSource(tvAnimatedDataSource))
54+
.bindTo(animatedTableView.rx.items(dataSource: tvAnimatedDataSource))
5555
.addDisposableTo(disposeBag)
5656

5757
randomSections
58-
.bindTo(tableView.rx_itemsWithDataSource(reloadDataSource))
58+
.bindTo(tableView.rx.items(dataSource: reloadDataSource))
5959
.addDisposableTo(disposeBag)
6060

6161
// Collection view logic works, but when clicking fast because of internal bugs
@@ -74,28 +74,28 @@ class ViewController: UIViewController {
7474
skinCollectionViewDataSource(cvAnimatedDataSource)
7575

7676
randomSections
77-
.bindTo(animatedCollectionView.rx_itemsWithDataSource(cvAnimatedDataSource))
77+
.bindTo(animatedCollectionView.rx.items(dataSource: cvAnimatedDataSource))
7878
.addDisposableTo(disposeBag)
7979
}
8080
else {
8181
let cvReloadDataSource = RxCollectionViewSectionedReloadDataSource<NumberSection>()
8282
skinCollectionViewDataSource(cvReloadDataSource)
8383
randomSections
84-
.bindTo(animatedCollectionView.rx_itemsWithDataSource(cvReloadDataSource))
84+
.bindTo(animatedCollectionView.rx.items(dataSource: cvReloadDataSource))
8585
.addDisposableTo(disposeBag)
8686
}
8787

8888
// touches
8989

9090
Observable.of(
91-
tableView.rx_modelSelected(IntItem.self),
92-
animatedTableView.rx_modelSelected(IntItem.self),
93-
animatedCollectionView.rx_modelSelected(IntItem.self)
91+
tableView.rx.modelSelected(IntItem.self),
92+
animatedTableView.rx.modelSelected(IntItem.self),
93+
animatedCollectionView.rx.modelSelected(IntItem.self)
9494
)
9595
.merge()
96-
.subscribeNext { item in
96+
.subscribe(onNext: { item in
9797
print("Let me guess, it's .... It's \(item), isn't it? Yeah, I've got it.")
98-
}
98+
})
9999
.addDisposableTo(disposeBag)
100100
}
101101
}

Example/Example3_TableViewEditing.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ class EditingExampleViewController: UIViewController {
2929

3030
let initialState = SectionedTableViewState(sections: sections)
3131
let add3ItemsAddStart = Observable.of((), (), ())
32-
let addCommand = Observable.of(addButton.rx_tap.asObservable(), add3ItemsAddStart)
32+
let addCommand = Observable.of(addButton.rx.tap.asObservable(), add3ItemsAddStart)
3333
.merge()
3434
.map(TableViewEditingCommand.addRandomItem)
3535

36-
let deleteCommand = tableView.rx_itemDeleted.asObservable()
36+
let deleteCommand = tableView.rx.itemDeleted.asObservable()
3737
.map(TableViewEditingCommand.DeleteItem)
3838

39-
let movedCommand = tableView.rx_itemMoved
39+
let movedCommand = tableView.rx.itemMoved
4040
.map(TableViewEditingCommand.MoveItem)
4141

4242
skinTableViewDataSource(dataSource: dataSource)
@@ -50,7 +50,7 @@ class EditingExampleViewController: UIViewController {
5050
$0.sections
5151
}
5252
.shareReplay(1)
53-
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
53+
.bindTo(tableView.rx.items(dataSource: dataSource))
5454
.addDisposableTo(disposeBag)
5555
}
5656

@@ -95,7 +95,7 @@ enum TableViewEditingCommand {
9595
// This is the part
9696

9797
struct SectionedTableViewState {
98-
private var sections: [NumberSection]
98+
fileprivate var sections: [NumberSection]
9999

100100
init(sections: [NumberSection]) {
101101
self.sections = sections

Example/Example4_DifferentSectionAndItemTypes.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MultipleSectionModelViewController: UIViewController {
3434
skinTableViewDataSource(dataSource)
3535

3636
Observable.just(sections)
37-
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
37+
.bindTo(tableView.rx.items(dataSource: dataSource))
3838
.addDisposableTo(disposeBag)
3939
}
4040

Example/Views/UIKitExtensions.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ protocol ReusableView: class {
1616

1717
extension ReusableView {
1818
static var reuseIdentifier: String {
19-
return String(self)
19+
return String(describing: self)
2020
}
2121
}
2222

@@ -25,7 +25,7 @@ extension UITableViewCell: ReusableView {
2525

2626
extension UITableView {
2727

28-
func dequeueReusableCell<T: UITableViewCell where T: ReusableView>(forIndexPath indexPath: IndexPath) -> T {
28+
func dequeueReusableCell<T: UITableViewCell>(forIndexPath indexPath: IndexPath) -> T where T: ReusableView {
2929
guard let cell = dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as? T else {
3030
fatalError("Could not dequeue cell with identifier: \(T.reuseIdentifier)")
3131
}

0 commit comments

Comments
 (0)