Skip to content

Commit 88457b1

Browse files
committed
Cleanup in RxExample app.
1 parent f536d6e commit 88457b1

File tree

1 file changed

+6
-43
lines changed

1 file changed

+6
-43
lines changed

Example/Example2_RandomizedSectionsAnimation.swift

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,6 @@ class NumberSectionView : UICollectionReusableView {
2020
@IBOutlet weak var value: UILabel?
2121
}
2222

23-
extension ObservableType {
24-
func implicitTransaction() -> Observable<E> {
25-
return Observable.create { observer in
26-
return self.subscribe { event in
27-
UIView.setAnimationDuration(5.0)
28-
//CATransaction.begin()
29-
//CATransaction.setAnimationDuration(5.0)
30-
//UIView.animate(withDuration: 3.0) {
31-
observer.on(event)
32-
//}
33-
//CATransaction.commit()
34-
}
35-
}
36-
}
37-
}
38-
3923
class ViewController: UIViewController {
4024

4125
@IBOutlet weak var animatedTableView: UITableView!
@@ -74,33 +58,12 @@ class ViewController: UIViewController {
7458
.bindTo(tableView.rx.items(dataSource: reloadDataSource))
7559
.addDisposableTo(disposeBag)
7660

77-
// Collection view logic works, but when clicking fast because of internal bugs
78-
// collection view will sometimes get confused. I know what you are thinking,
79-
// but this is really not a bug in the algorithm. The generated changes are
80-
// pseudorandom, and crash happens depending on clicking speed.
81-
//
82-
// If you want, turn this to true, just click slow :)
83-
//
84-
// While `useAnimatedUpdateForCollectionView` is false, you can click as fast as
85-
// you want, table view doesn't seem to have same issues like collection view.
86-
87-
let useAnimatedUpdates = true
88-
if useAnimatedUpdates {
89-
let cvAnimatedDataSource = RxCollectionViewSectionedAnimatedDataSource<NumberSection>()
90-
skinCollectionViewDataSource(cvAnimatedDataSource)
91-
92-
randomSections
93-
.implicitTransaction()
94-
.bindTo(animatedCollectionView.rx.items(dataSource: cvAnimatedDataSource))
95-
.addDisposableTo(disposeBag)
96-
}
97-
else {
98-
let cvReloadDataSource = RxCollectionViewSectionedReloadDataSource<NumberSection>()
99-
skinCollectionViewDataSource(cvReloadDataSource)
100-
randomSections
101-
.bindTo(animatedCollectionView.rx.items(dataSource: cvReloadDataSource))
102-
.addDisposableTo(disposeBag)
103-
}
61+
let cvAnimatedDataSource = RxCollectionViewSectionedAnimatedDataSource<NumberSection>()
62+
skinCollectionViewDataSource(cvAnimatedDataSource)
63+
64+
randomSections
65+
.bindTo(animatedCollectionView.rx.items(dataSource: cvAnimatedDataSource))
66+
.addDisposableTo(disposeBag)
10467

10568
// touches
10669

0 commit comments

Comments
 (0)