RxCocoa: Rename S generic constraint to Sequence

This commit is contained in:
freak4pc 2019-04-24 23:30:36 +03:00 committed by Krunoslav Zaher
parent 786521f83a
commit 5eb3c2bc09
8 changed files with 48 additions and 48 deletions

View File

@ -353,8 +353,8 @@ extension SharedSequence {
- returns: An observable sequence that contains the elements of each given sequence, in sequential order.
*/
public static func concat<S: Sequence>(_ sequence: S) -> SharedSequence<SharingStrategy, Element>
where S.Iterator.Element == SharedSequence<SharingStrategy, Element> {
public static func concat<Sequence: Swift.Sequence>(_ sequence: Sequence) -> SharedSequence<SharingStrategy, Element>
where Sequence.Element == SharedSequence<SharingStrategy, Element> {
let source = Observable.concat(sequence.lazy.map { $0.asObservable() })
return SharedSequence<SharingStrategy, Element>(source)
}

View File

@ -39,8 +39,8 @@ public struct SharedSequence<S: SharingStrategyProtocol, Element> : SharedSequen
By defining `EXPANDABLE_SHARED_SEQUENCE` one agrees that it's up to him to ensure shared sequence
properties are preserved after extension.
*/
public static func createUnsafe<O: ObservableType>(source: O) -> SharedSequence<S, O.Element> {
return SharedSequence<S, O.Element>(raw: source.asObservable())
public static func createUnsafe<O: ObservableType>(source: O) -> SharedSequence<Sequence, O.Element> {
return SharedSequence<Sequence, O.Element>(raw: source.asObservable())
}
#endif
@ -173,7 +173,7 @@ extension SharedSequence {
- returns: The observable sequence whose elements are pulled from the given enumerable sequence.
*/
public static func from<S: Sequence>(_ sequence: S) -> SharedSequence<SharingStrategy, Element> where S.Iterator.Element == Element {
public static func from<Sequence: Swift.Sequence>(_ sequence: Sequence) -> SharedSequence<SharingStrategy, Element> where Sequence.Element == Element {
let source = Observable.from(sequence, scheduler: SharingStrategy.scheduler)
return SharedSequence(raw: source)
}

View File

@ -38,16 +38,16 @@ class _RxCollectionViewReactiveArrayDataSource
}
}
class RxCollectionViewReactiveArrayDataSourceSequenceWrapper<S: Sequence>
: RxCollectionViewReactiveArrayDataSource<S.Iterator.Element>
class RxCollectionViewReactiveArrayDataSourceSequenceWrapper<Sequence: Swift.Sequence>
: RxCollectionViewReactiveArrayDataSource<Sequence.Element>
, RxCollectionViewDataSourceType {
typealias Element = S
typealias Element = Sequence
override init(cellFactory: @escaping CellFactory) {
super.init(cellFactory: cellFactory)
}
func collectionView(_ collectionView: UICollectionView, observedEvent: Event<S>) {
func collectionView(_ collectionView: UICollectionView, observedEvent: Event<Sequence>) {
Binder(self) { collectionViewDataSource, sectionModels in
let sections = Array(sectionModels)
collectionViewDataSource.collectionView(collectionView, observedElements: sections)

View File

@ -30,12 +30,12 @@ class RxPickerViewArrayDataSource<T>: NSObject, UIPickerViewDataSource, Sectione
}
}
class RxPickerViewSequenceDataSource<S: Sequence>
: RxPickerViewArrayDataSource<S.Iterator.Element>
class RxPickerViewSequenceDataSource<Sequence: Swift.Sequence>
: RxPickerViewArrayDataSource<Sequence.Element>
, RxPickerViewDataSourceType {
typealias Element = S
typealias Element = Sequence
func pickerView(_ pickerView: UIPickerView, observedEvent: Event<S>) {
func pickerView(_ pickerView: UIPickerView, observedEvent: Event<Sequence>) {
Binder(self) { dataSource, items in
dataSource.items = items
pickerView.reloadAllComponents()
@ -44,11 +44,11 @@ class RxPickerViewSequenceDataSource<S: Sequence>
}
}
final class RxStringPickerViewAdapter<S: Sequence>
: RxPickerViewSequenceDataSource<S>
final class RxStringPickerViewAdapter<Sequence: Swift.Sequence>
: RxPickerViewSequenceDataSource<Sequence>
, UIPickerViewDelegate {
typealias TitleForRow = (Int, S.Iterator.Element) -> String?
typealias TitleForRow = (Int, Sequence.Element) -> String?
private let titleForRow: TitleForRow
init(titleForRow: @escaping TitleForRow) {
@ -61,8 +61,8 @@ final class RxStringPickerViewAdapter<S: Sequence>
}
}
final class RxAttributedStringPickerViewAdapter<S: Sequence>: RxPickerViewSequenceDataSource<S>, UIPickerViewDelegate {
typealias AttributedTitleForRow = (Int, S.Iterator.Element) -> NSAttributedString?
final class RxAttributedStringPickerViewAdapter<Sequence: Swift.Sequence>: RxPickerViewSequenceDataSource<Sequence>, UIPickerViewDelegate {
typealias AttributedTitleForRow = (Int, Sequence.Element) -> NSAttributedString?
private let attributedTitleForRow: AttributedTitleForRow
init(attributedTitleForRow: @escaping AttributedTitleForRow) {
@ -75,8 +75,8 @@ final class RxAttributedStringPickerViewAdapter<S: Sequence>: RxPickerViewSequen
}
}
final class RxPickerViewAdapter<S: Sequence>: RxPickerViewSequenceDataSource<S>, UIPickerViewDelegate {
typealias ViewForRow = (Int, S.Iterator.Element, UIView?) -> UIView
final class RxPickerViewAdapter<Sequence: Swift.Sequence>: RxPickerViewSequenceDataSource<Sequence>, UIPickerViewDelegate {
typealias ViewForRow = (Int, Sequence.Element, UIView?) -> UIView
private let viewForRow: ViewForRow
init(viewForRow: @escaping ViewForRow) {

View File

@ -38,16 +38,16 @@ class _RxTableViewReactiveArrayDataSource
}
class RxTableViewReactiveArrayDataSourceSequenceWrapper<S: Sequence>
: RxTableViewReactiveArrayDataSource<S.Iterator.Element>
class RxTableViewReactiveArrayDataSourceSequenceWrapper<Sequence: Swift.Sequence>
: RxTableViewReactiveArrayDataSource<Sequence.Element>
, RxTableViewDataSourceType {
typealias Element = S
typealias Element = Sequence
override init(cellFactory: @escaping CellFactory) {
super.init(cellFactory: cellFactory)
}
func tableView(_ tableView: UITableView, observedEvent: Event<S>) {
func tableView(_ tableView: UITableView, observedEvent: Event<Sequence>) {
Binder(self) { tableViewDataSource, sectionModels in
let sections = Array(sectionModels)
tableViewDataSource.tableView(tableView, observedElements: sections)

View File

@ -39,12 +39,12 @@ extension Reactive where Base: UICollectionView {
}
.disposed(by: disposeBag)
*/
public func items<S: Sequence, O: ObservableType>
public func items<Sequence: Swift.Sequence, O: ObservableType>
(_ source: O)
-> (_ cellFactory: @escaping (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell)
-> Disposable where O.Element == S {
-> (_ cellFactory: @escaping (UICollectionView, Int, Sequence.Element) -> UICollectionViewCell)
-> Disposable where O.Element == Sequence {
return { cellFactory in
let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper<S>(cellFactory: cellFactory)
let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper<Sequence>(cellFactory: cellFactory)
return self.items(dataSource: dataSource)(source)
}

View File

@ -104,12 +104,12 @@
*/
public func itemTitles<S: Sequence, O: ObservableType>
public func itemTitles<Sequence: Swift.Sequence, O: ObservableType>
(_ source: O)
-> (_ titleForRow: @escaping (Int, S.Iterator.Element) -> String?)
-> Disposable where O.Element == S {
-> (_ titleForRow: @escaping (Int, Sequence.Element) -> String?)
-> Disposable where O.Element == Sequence {
return { titleForRow in
let adapter = RxStringPickerViewAdapter<S>(titleForRow: titleForRow)
let adapter = RxStringPickerViewAdapter<Sequence>(titleForRow: titleForRow)
return self.items(adapter: adapter)(source)
}
}
@ -137,12 +137,12 @@
*/
public func itemAttributedTitles<S: Sequence, O: ObservableType>
public func itemAttributedTitles<Sequence: Swift.Sequence, O: ObservableType>
(_ source: O)
-> (_ attributedTitleForRow: @escaping (Int, S.Iterator.Element) -> NSAttributedString?)
-> Disposable where O.Element == S {
-> (_ attributedTitleForRow: @escaping (Int, Sequence.Element) -> NSAttributedString?)
-> Disposable where O.Element == Sequence {
return { attributedTitleForRow in
let adapter = RxAttributedStringPickerViewAdapter<S>(attributedTitleForRow: attributedTitleForRow)
let adapter = RxAttributedStringPickerViewAdapter<Sequence>(attributedTitleForRow: attributedTitleForRow)
return self.items(adapter: adapter)(source)
}
}
@ -176,12 +176,12 @@
*/
public func items<S: Sequence, O: ObservableType>
public func items<Sequence: Swift.Sequence, O: ObservableType>
(_ source: O)
-> (_ viewForRow: @escaping (Int, S.Iterator.Element, UIView?) -> UIView)
-> Disposable where O.Element == S {
-> (_ viewForRow: @escaping (Int, Sequence.Element, UIView?) -> UIView)
-> Disposable where O.Element == Sequence {
return { viewForRow in
let adapter = RxPickerViewAdapter<S>(viewForRow: viewForRow)
let adapter = RxPickerViewAdapter<Sequence>(viewForRow: viewForRow)
return self.items(adapter: adapter)(source)
}
}

View File

@ -39,13 +39,13 @@ extension Reactive where Base: UITableView {
.disposed(by: disposeBag)
*/
public func items<S: Sequence, O: ObservableType>
public func items<Sequence: Swift.Sequence, O: ObservableType>
(_ source: O)
-> (_ cellFactory: @escaping (UITableView, Int, S.Iterator.Element) -> UITableViewCell)
-> (_ cellFactory: @escaping (UITableView, Int, Sequence.Element) -> UITableViewCell)
-> Disposable
where O.Element == S {
where O.Element == Sequence {
return { cellFactory in
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S>(cellFactory: cellFactory)
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<Sequence>(cellFactory: cellFactory)
return self.items(dataSource: dataSource)(source)
}
}
@ -73,15 +73,15 @@ extension Reactive where Base: UITableView {
}
.disposed(by: disposeBag)
*/
public func items<S: Sequence, Cell: UITableViewCell, O : ObservableType>
public func items<Sequence: Swift.Sequence, Cell: UITableViewCell, O : ObservableType>
(cellIdentifier: String, cellType: Cell.Type = Cell.self)
-> (_ source: O)
-> (_ configureCell: @escaping (Int, S.Iterator.Element, Cell) -> Void)
-> (_ configureCell: @escaping (Int, Sequence.Element, Cell) -> Void)
-> Disposable
where O.Element == S {
where O.Element == Sequence {
return { source in
return { configureCell in
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S> { tv, i, item in
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<Sequence> { tv, i, item in
let indexPath = IndexPath(item: i, section: 0)
let cell = tv.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! Cell
configureCell(i, item, cell)