Skip to content

Commit cefd3b4

Browse files
committed
Add documentation for RxPickerViewAdapter
1 parent 26867f8 commit cefd3b4

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

Sources/DataSources+Rx/RxPickerViewAdapter.swift

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ import UIKit
1313
import RxCocoa
1414
#endif
1515

16+
/// A reactive UIPickerView adapter which uses `func pickerView(UIPickerView, titleForRow: Int, forComponent: Int)` to desplay content
17+
/**
18+
Example:
19+
20+
let adapter = RxPickerViewStringAdapter<[T]>(...)
21+
22+
items
23+
.bind(to: firstPickerView.rx.items(adapter: adapter))
24+
.disposed(by: disposeBag)
25+
26+
*/
1627
open class RxPickerViewStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDelegate {
1728
public typealias TitleForRow = (RxPickerViewStringAdapter<T>, UIPickerView, T,Int, Int) -> String?
1829

@@ -33,6 +44,17 @@ open class RxPickerViewStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerView
3344
}
3445
}
3546

47+
/// A reactive UIPickerView adapter which uses `func pickerView(UIPickerView, viewForRow: Int, forComponent: Int, reusing: UIView?)` to desplay content
48+
/**
49+
Example:
50+
51+
let adapter = RxPickerViewAttributedStringAdapter<[T]>(...)
52+
53+
items
54+
.bind(to: firstPickerView.rx.items(adapter: adapter))
55+
.disposed(by: disposeBag)
56+
57+
*/
3658
open class RxPickerViewAttributedStringAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDelegate {
3759
public typealias AttributedTitleForRow = (RxPickerViewAttributedStringAdapter<T>, UIPickerView, T, Int, Int) -> NSAttributedString?
3860

@@ -53,6 +75,17 @@ open class RxPickerViewAttributedStringAdapter<T>: RxPickerViewDataSource<T>, UI
5375
}
5476
}
5577

78+
/// A reactive UIPickerView adapter which uses `func pickerView(pickerView:, viewForRow row:, forComponent component:)` to desplay content
79+
/**
80+
Example:
81+
82+
let adapter = RxPickerViewViewAdapter<[T]>(...)
83+
84+
items
85+
.bind(to: firstPickerView.rx.items(adapter: adapter))
86+
.disposed(by: disposeBag)
87+
88+
*/
5689
open class RxPickerViewViewAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDelegate {
5790
public typealias ViewForRow = (RxPickerViewViewAdapter<T>, UIPickerView, T, Int, Int, UIView?) -> UIView
5891

@@ -73,7 +106,7 @@ open class RxPickerViewViewAdapter<T>: RxPickerViewDataSource<T>, UIPickerViewDe
73106
}
74107
}
75108

76-
109+
/// A reactive UIPickerView data source
77110
open class RxPickerViewDataSource<T>: NSObject, UIPickerViewDataSource {
78111
public typealias NumberOfComponents = (RxPickerViewDataSource, UIPickerView, T) -> Int
79112
public typealias NumberOfRowsInComponent = (RxPickerViewDataSource, UIPickerView, T, Int) -> Int
@@ -108,6 +141,6 @@ extension RxPickerViewDataSource: RxPickerViewDataSourceType {
108141
UIBindingObserver(UIElement: self) { (dataSource, components) in
109142
dataSource.components = components
110143
pickerView.reloadAllComponents()
111-
}.on(observedEvent)
144+
}.on(observedEvent)
112145
}
113146
}

0 commit comments

Comments
 (0)