Modernizes UICollectionView extensions.
This commit is contained in:
parent
1b0e0a3c88
commit
afd40f5d8b
|
|
@ -42,6 +42,7 @@ extension UICollectionView {
|
|||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
@available(*, deprecated, renamed: "rx_items(source:cellFactory:)")
|
||||
public func rx_itemsWithCellFactory<S: Sequence, O: ObservableType where O.E == S>
|
||||
(_ source: O)
|
||||
-> (cellFactory: (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell)
|
||||
|
|
@ -56,6 +57,41 @@ extension UICollectionView {
|
|||
/**
|
||||
Binds sequences of elements to collection view items.
|
||||
|
||||
- parameter source: Observable sequence of items.
|
||||
- parameter cellFactory: Transform between sequence elements and view cells.
|
||||
- returns: Disposable object that can be used to unbind.
|
||||
|
||||
Example
|
||||
|
||||
let items = Observable.just([
|
||||
1,
|
||||
2,
|
||||
3
|
||||
])
|
||||
|
||||
items
|
||||
.bindTo(collectionView.rx_items) { (collectionView, row, element) in
|
||||
let indexPath = IndexPath(forItem: row, inSection: 0)
|
||||
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell
|
||||
cell.value?.text = "\(element) @ \(row)"
|
||||
return cell
|
||||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
public func rx_items<S: Sequence, O: ObservableType where O.E == S>
|
||||
(source: O)
|
||||
-> (cellFactory: (UICollectionView, Int, S.Iterator.Element) -> UICollectionViewCell)
|
||||
-> Disposable {
|
||||
return { cellFactory in
|
||||
let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper<S>(cellFactory: cellFactory)
|
||||
return self.rx_items(dataSource: dataSource)(source: source)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Binds sequences of elements to collection view items.
|
||||
|
||||
- parameter cellIdentifier: Identifier used to dequeue cells.
|
||||
- parameter source: Observable sequence of items.
|
||||
- parameter configureCell: Transform between sequence elements and view cells.
|
||||
|
|
@ -76,6 +112,7 @@ extension UICollectionView {
|
|||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
@available(*, deprecated, renamed: "rx_items(cellIdentifier:cellType:source:configureCell:)")
|
||||
public func rx_itemsWithCellIdentifier<S: Sequence, Cell: UICollectionViewCell, O : ObservableType where O.E == S>
|
||||
(_ cellIdentifier: String, cellType: Cell.Type = Cell.self)
|
||||
-> (source: O)
|
||||
|
|
@ -94,6 +131,49 @@ extension UICollectionView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Binds sequences of elements to collection view items.
|
||||
|
||||
- parameter cellIdentifier: Identifier used to dequeue cells.
|
||||
- parameter source: Observable sequence of items.
|
||||
- parameter configureCell: Transform between sequence elements and view cells.
|
||||
- parameter cellType: Type of table view cell.
|
||||
- returns: Disposable object that can be used to unbind.
|
||||
|
||||
Example
|
||||
|
||||
let items = Observable.just([
|
||||
1,
|
||||
2,
|
||||
3
|
||||
])
|
||||
|
||||
items
|
||||
.bindTo(collectionView.rx_items(cellIdentifier: "Cell", cellType: NumberCell.self)) { (row, element, cell) in
|
||||
cell.value?.text = "\(element) @ \(row)"
|
||||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
public func rx_items<S: Sequence, Cell: UICollectionViewCell, O : ObservableType where O.E == S>
|
||||
(cellIdentifier: String, cellType: Cell.Type = Cell.self)
|
||||
-> (source: O)
|
||||
-> (configureCell: (Int, S.Iterator.Element, Cell) -> Void)
|
||||
-> Disposable {
|
||||
return { source in
|
||||
return { configureCell in
|
||||
let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper<S> { (cv, i, item) in
|
||||
let indexPath = IndexPath(item: i, section: 0)
|
||||
let cell = cv.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! Cell
|
||||
configureCell(i, item, cell)
|
||||
return cell
|
||||
}
|
||||
|
||||
return self.rx_items(dataSource: dataSource)(source: source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation.
|
||||
|
|
@ -134,6 +214,7 @@ extension UICollectionView {
|
|||
.bindTo(collectionView.rx_itemsWithDataSource(dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
@available(*, deprecated, renamed: "rx_items(dataSource:source:)")
|
||||
public func rx_itemsWithDataSource<
|
||||
DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource,
|
||||
O: ObservableType where DataSource.Element == O.E
|
||||
|
|
@ -151,6 +232,63 @@ extension UICollectionView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Binds sequences of elements to collection view items using a custom reactive data used to perform the transformation.
|
||||
|
||||
- parameter dataSource: Data source used to transform elements to view cells.
|
||||
- parameter source: Observable sequence of items.
|
||||
- returns: Disposable object that can be used to unbind.
|
||||
|
||||
Example
|
||||
|
||||
let dataSource = RxCollectionViewSectionedReloadDataSource<SectionModel<String, Double>>()
|
||||
|
||||
let items = Observable.just([
|
||||
SectionModel(model: "First section", items: [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]),
|
||||
SectionModel(model: "Second section", items: [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]),
|
||||
SectionModel(model: "Third section", items: [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
])
|
||||
])
|
||||
|
||||
dataSource.configureCell = { (dataSource, cv, indexPath, element) in
|
||||
let cell = cv.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as! NumberCell
|
||||
cell.value?.text = "\(element) @ row \(indexPath.row)"
|
||||
return cell
|
||||
}
|
||||
|
||||
items
|
||||
.bindTo(collectionView.rx_items(dataSource: dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
public func rx_items<
|
||||
DataSource: RxCollectionViewDataSourceType & UICollectionViewDataSource,
|
||||
O: ObservableType where DataSource.Element == O.E
|
||||
>
|
||||
(dataSource: DataSource)
|
||||
-> (source: O)
|
||||
-> Disposable {
|
||||
return { source in
|
||||
|
||||
return source.subscribeProxyDataSourceForObject(self, dataSource: dataSource, retainDataSource: true) { [weak self] (_: RxCollectionViewDataSourceProxy, event) -> Void in
|
||||
guard let collectionView = self else {
|
||||
return
|
||||
}
|
||||
dataSource.collectionView(collectionView, observedEvent: event)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension UICollectionView {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ extension UITableView {
|
|||
.addDisposableTo(disposeBag)
|
||||
|
||||
*/
|
||||
@available(*, deprecated, renamed: "rx_items(source:cellFactory:)")
|
||||
public func rx_itemsWithCellFactory<S: Sequence, O: ObservableType where O.E == S>
|
||||
(_ source: O)
|
||||
-> (cellFactory: (UITableView, Int, S.Iterator.Element) -> UITableViewCell)
|
||||
|
|
@ -49,13 +50,48 @@ extension UITableView {
|
|||
return { cellFactory in
|
||||
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S>(cellFactory: cellFactory)
|
||||
|
||||
return self.rx_itemsWithDataSource(dataSource)(source: source)
|
||||
return self.rx_items(dataSource: dataSource)(source: source)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Binds sequences of elements to table view rows.
|
||||
|
||||
- parameter source: Observable sequence of items.
|
||||
- parameter cellFactory: Transform between sequence elements and view cells.
|
||||
- returns: Disposable object that can be used to unbind.
|
||||
|
||||
Example:
|
||||
|
||||
let items = Observable.just([
|
||||
"First Item",
|
||||
"Second Item",
|
||||
"Third Item"
|
||||
])
|
||||
|
||||
items
|
||||
.bindTo(tableView.rx_items) { (tableView, row, element) in
|
||||
let cell = tableView.dequeueReusableCellWithIdentifier("Cell")!
|
||||
cell.textLabel?.text = "\(element) @ row \(row)"
|
||||
return cell
|
||||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
*/
|
||||
public func rx_items<S: Sequence, O: ObservableType where O.E == S>
|
||||
(_ source: O)
|
||||
-> (cellFactory: (UITableView, Int, S.Iterator.Element) -> UITableViewCell)
|
||||
-> Disposable {
|
||||
return { cellFactory in
|
||||
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S>(cellFactory: cellFactory)
|
||||
|
||||
return self.rx_items(dataSource: dataSource)(source: source)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Binds sequences of elements to table view rows.
|
||||
|
||||
- parameter cellIdentifier: Identifier used to dequeue cells.
|
||||
- parameter source: Observable sequence of items.
|
||||
- parameter configureCell: Transform between sequence elements and view cells.
|
||||
|
|
@ -76,6 +112,7 @@ extension UITableView {
|
|||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
@available(*, deprecated, renamed: "rx_items(cellIdentifier:cellType:source:configureCell:)")
|
||||
public func rx_itemsWithCellIdentifier<S: Sequence, Cell: UITableViewCell, O : ObservableType where O.E == S>
|
||||
(_ cellIdentifier: String, cellType: Cell.Type = Cell.self)
|
||||
-> (source: O)
|
||||
|
|
@ -93,6 +130,48 @@ extension UITableView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Binds sequences of elements to table view rows.
|
||||
|
||||
- parameter cellIdentifier: Identifier used to dequeue cells.
|
||||
- parameter source: Observable sequence of items.
|
||||
- parameter configureCell: Transform between sequence elements and view cells.
|
||||
- parameter cellType: Type of table view cell.
|
||||
- returns: Disposable object that can be used to unbind.
|
||||
|
||||
Example:
|
||||
|
||||
let items = Observable.just([
|
||||
"First Item",
|
||||
"Second Item",
|
||||
"Third Item"
|
||||
])
|
||||
|
||||
items
|
||||
.bindTo(tableView.rx_items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in
|
||||
cell.textLabel?.text = "\(element) @ row \(row)"
|
||||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
public func rx_items<S: Sequence, Cell: UITableViewCell, O : ObservableType where O.E == S>
|
||||
(cellIdentifier: String, cellType: Cell.Type = Cell.self)
|
||||
-> (source: O)
|
||||
-> (configureCell: (Int, S.Iterator.Element, Cell) -> Void)
|
||||
-> Disposable {
|
||||
return { source in
|
||||
return { configureCell in
|
||||
let dataSource = RxTableViewReactiveArrayDataSourceSequenceWrapper<S> { (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)
|
||||
return cell
|
||||
}
|
||||
return self.rx_items(dataSource: dataSource)(source: source)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation.
|
||||
|
|
@ -137,6 +216,7 @@ extension UITableView {
|
|||
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
@available(*, deprecated, renamed: "rx_items(dataSource:source:)")
|
||||
public func rx_itemsWithDataSource<
|
||||
DataSource: RxTableViewDataSourceType & UITableViewDataSource,
|
||||
O: ObservableType where DataSource.Element == O.E
|
||||
|
|
@ -154,6 +234,69 @@ extension UITableView {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Binds sequences of elements to table view rows using a custom reactive data used to perform the transformation.
|
||||
This method will retain the data source for as long as the subscription isn't disposed (result `Disposable`
|
||||
being disposed).
|
||||
In case `source` observable sequence terminates sucessfully, the data source will present latest element
|
||||
until the subscription isn't disposed.
|
||||
|
||||
- parameter dataSource: Data source used to transform elements to view cells.
|
||||
- parameter source: Observable sequence of items.
|
||||
- returns: Disposable object that can be used to unbind.
|
||||
|
||||
Example
|
||||
|
||||
let dataSource = RxTableViewSectionedReloadDataSource<SectionModel<String, Double>>()
|
||||
|
||||
let items = Observable.just([
|
||||
SectionModel(model: "First section", items: [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]),
|
||||
SectionModel(model: "Second section", items: [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
]),
|
||||
SectionModel(model: "Third section", items: [
|
||||
1.0,
|
||||
2.0,
|
||||
3.0
|
||||
])
|
||||
])
|
||||
|
||||
dataSource.configureCell = { (dataSource, tv, indexPath, element) in
|
||||
let cell = tv.dequeueReusableCellWithIdentifier("Cell")!
|
||||
cell.textLabel?.text = "\(element) @ row \(indexPath.row)"
|
||||
return cell
|
||||
}
|
||||
|
||||
items
|
||||
.bindTo(tableView.rx_items(dataSource: dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
*/
|
||||
public func rx_items<
|
||||
DataSource: RxTableViewDataSourceType & UITableViewDataSource,
|
||||
O: ObservableType where DataSource.Element == O.E
|
||||
>
|
||||
(dataSource: DataSource)
|
||||
-> (source: O)
|
||||
-> Disposable {
|
||||
return { source in
|
||||
// There needs to be a strong retaining here because
|
||||
return source.subscribeProxyDataSourceForObject(self, dataSource: dataSource, retainDataSource: true) { [weak self] (_: RxTableViewDataSourceProxy, event) -> Void in
|
||||
guard let tableView = self else {
|
||||
return
|
||||
}
|
||||
dataSource.tableView(tableView, observedEvent: event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension UITableView {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class GitHubSearchRepositoriesViewController: ViewController, UITableViewDelegat
|
|||
|
||||
searchResult
|
||||
.map { [SectionModel(model: "Repositories", items: $0.repositories)] }
|
||||
.drive(tableView.rx_itemsWithDataSource(dataSource))
|
||||
.drive(tableView.rx_items(dataSource: dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
searchResult
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class SimpleTableViewExampleViewController : ViewController {
|
|||
])
|
||||
|
||||
items
|
||||
.bindTo(tableView.rx_itemsWithCellIdentifier("Cell", cellType: UITableViewCell.self)) { (row, element, cell) in
|
||||
.bindTo(tableView.rx_items(cellIdentifier: "Cell", cellType: UITableViewCell.self)) { (row, element, cell) in
|
||||
cell.textLabel?.text = "\(element) @ row \(row)"
|
||||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class SimpleTableViewExampleSectionedViewController
|
|||
}
|
||||
|
||||
items
|
||||
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
|
||||
.bindTo(tableView.rx_items(dataSource: dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
tableView
|
||||
|
|
|
|||
|
|
@ -85,11 +85,11 @@ class PartialUpdatesViewController : ViewController {
|
|||
skinTableViewDataSource(reloadDataSource)
|
||||
|
||||
self.sections.asObservable()
|
||||
.bindTo(partialUpdatesTableViewOutlet.rx_itemsWithDataSource(tvAnimatedDataSource))
|
||||
.bindTo(partialUpdatesTableViewOutlet.rx_items(dataSource: tvAnimatedDataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
self.sections.asObservable()
|
||||
.bindTo(reloadTableViewOutlet.rx_itemsWithDataSource(reloadDataSource))
|
||||
.bindTo(reloadTableViewOutlet.rx_items(dataSource: reloadDataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
// Collection view logic works, but when clicking fast because of internal bugs
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class TableViewWithEditingCommandsViewController: ViewController, UITableViewDel
|
|||
SectionModel(model: "Normal Users", items: $0.users)
|
||||
]
|
||||
}
|
||||
.bindTo(tableView.rx_itemsWithDataSource(dataSource))
|
||||
.bindTo(tableView.rx_items(dataSource: dataSource))
|
||||
.addDisposableTo(disposeBag)
|
||||
|
||||
tableView.rx_itemSelected
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ class WikipediaSearchViewController: ViewController {
|
|||
.map { results in
|
||||
results.map(SearchResultViewModel.init)
|
||||
}
|
||||
.drive(resultsTableView.rx_itemsWithCellIdentifier("WikipediaSearchCell", cellType: WikipediaSearchCell.self)) { (_, viewModel, cell) in
|
||||
.drive(resultsTableView.rx_items(cellIdentifier: "WikipediaSearchCell", cellType: WikipediaSearchCell.self)) { (_, viewModel, cell) in
|
||||
cell.viewModel = viewModel
|
||||
}
|
||||
.addDisposableTo(disposeBag)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class UICollectionViewTests : RxTest {
|
|||
let layout = UICollectionViewFlowLayout()
|
||||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
let s = items.bindTo(collectionView.rx_itemsWithCellFactory) { (cv, index: Int, item: Int) -> UICollectionViewCell in
|
||||
let s = items.bindTo(collectionView.rx_items) { (cv, index: Int, item: Int) -> UICollectionViewCell in
|
||||
return UICollectionViewCell(frame: CGRect(x: 1, y: 1, width: 1, height: 1))
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ class UICollectionViewTests : RxTest {
|
|||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(NSClassFromString("UICollectionViewCell"), forCellWithReuseIdentifier: "a")
|
||||
let s = items.bindTo(collectionView.rx_itemsWithCellIdentifier("a")) { (index: Int, item: Int, cell) in
|
||||
let s = items.bindTo(collectionView.rx_items(cellIdentifier: "a")) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ class UICollectionViewTests : RxTest {
|
|||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(NSClassFromString("UICollectionViewCell"), forCellWithReuseIdentifier: "a")
|
||||
let s = items.bindTo(collectionView.rx_itemsWithCellIdentifier("a", cellType: UICollectionViewCell.self)) { (index: Int, item: Int, cell) in
|
||||
let s = items.bindTo(collectionView.rx_items(cellIdentifier: "a", cellType: UICollectionViewCell.self)) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ class UICollectionViewTests : RxTest {
|
|||
|
||||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
let s = items.bindTo(collectionView.rx_itemsWithCellFactory) { (cv, index: Int, item: Int) -> UICollectionViewCell in
|
||||
let s = items.bindTo(collectionView.rx_items) { (cv, index: Int, item: Int) -> UICollectionViewCell in
|
||||
return UICollectionViewCell(frame: CGRect(x: 1, y: 1, width: 1, height: 1))
|
||||
}
|
||||
|
||||
|
|
@ -147,7 +147,7 @@ class UICollectionViewTests : RxTest {
|
|||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(NSClassFromString("UICollectionViewCell"), forCellWithReuseIdentifier: "a")
|
||||
let dataSourceSubscription = items.bindTo(collectionView.rx_itemsWithCellIdentifier("a")) { (index: Int, item: Int, cell) in
|
||||
let dataSourceSubscription = items.bindTo(collectionView.rx_items(cellIdentifier: "a")) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -178,7 +178,7 @@ class UICollectionViewTests : RxTest {
|
|||
|
||||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
let s = items.bindTo(collectionView.rx_itemsWithCellFactory) { (cv, index: Int, item: Int) -> UICollectionViewCell in
|
||||
let s = items.bindTo(collectionView.rx_items) { (cv, index: Int, item: Int) -> UICollectionViewCell in
|
||||
return UICollectionViewCell(frame: CGRect(x: 1, y: 1, width: 1, height: 1))
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ class UICollectionViewTests : RxTest {
|
|||
let createView: () -> (UICollectionView, Disposable) = {
|
||||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(NSClassFromString("UICollectionViewCell"), forCellWithReuseIdentifier: "a")
|
||||
let dataSourceSubscription = items.bindTo(collectionView.rx_itemsWithCellIdentifier("a")) { (index: Int, item: Int, cell) in
|
||||
let dataSourceSubscription = items.bindTo(collectionView.rx_items(cellIdentifier: "a")) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ class UICollectionViewTests : RxTest {
|
|||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(NSClassFromString("UICollectionViewCell"), forCellWithReuseIdentifier: "a")
|
||||
let dataSource = SectionedViewDataSourceMock()
|
||||
let dataSourceSubscription = items.bindTo(collectionView.rx_itemsWithDataSource(dataSource))
|
||||
let dataSourceSubscription = items.bindTo(collectionView.rx_items(dataSource: dataSource))
|
||||
|
||||
return (collectionView, dataSourceSubscription)
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ extension UICollectionViewTests {
|
|||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "a")
|
||||
let dataSource = SectionedViewDataSourceMock()
|
||||
dataSourceSubscription = items.bindTo(collectionView.rx_itemsWithDataSource(dataSource))
|
||||
dataSourceSubscription = items.bindTo(collectionView.rx_items(dataSource: dataSource))
|
||||
|
||||
_ = dataSource.rx_deallocated.subscribeNext { _ in
|
||||
dataSourceDeallocated = true
|
||||
|
|
@ -291,7 +291,7 @@ extension UICollectionViewTests {
|
|||
let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), collectionViewLayout: layout)
|
||||
collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "a")
|
||||
let dataSource = SectionedViewDataSourceMock()
|
||||
_ = items.bindTo(collectionView.rx_itemsWithDataSource(dataSource))
|
||||
_ = items.bindTo(collectionView.rx_items(dataSource: dataSource))
|
||||
|
||||
_ = dataSource.rx_deallocated.subscribeNext { _ in
|
||||
dataSourceDeallocated = true
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ class UITableViewTests : RxTest {
|
|||
|
||||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellFactory) { (tv, index: Int, item: Int) -> UITableViewCell in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items) { (tv, index: Int, item: Int) -> UITableViewCell in
|
||||
return UITableViewCell(style: .default, reuseIdentifier: "Identity")
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ class UITableViewTests : RxTest {
|
|||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
tableView.register(NSClassFromString("UITableViewCell"), forCellReuseIdentifier: "a")
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellIdentifier("a")) { (index: Int, item: Int, cell) in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items(cellIdentifier: "a")) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -211,7 +211,7 @@ class UITableViewTests : RxTest {
|
|||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
tableView.register(NSClassFromString("UITableViewCell"), forCellReuseIdentifier: "a")
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellIdentifier("a", cellType: UITableViewCell.self)) { (index: Int, item: Int, cell) in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items(cellIdentifier: "a", cellType: UITableViewCell.self)) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ class UITableViewTests : RxTest {
|
|||
|
||||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellFactory) { (tv, index: Int, item: Int) -> UITableViewCell in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items) { (tv, index: Int, item: Int) -> UITableViewCell in
|
||||
return UITableViewCell(style: .default, reuseIdentifier: "Identity")
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ class UITableViewTests : RxTest {
|
|||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
tableView.register(NSClassFromString("UITableViewCell"), forCellReuseIdentifier: "a")
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellIdentifier("a")) { (index: Int, item: Int, cell) in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items(cellIdentifier: "a")) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -284,7 +284,7 @@ class UITableViewTests : RxTest {
|
|||
|
||||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellFactory) { (tv, index: Int, item: Int) -> UITableViewCell in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items) { (tv, index: Int, item: Int) -> UITableViewCell in
|
||||
return UITableViewCell(style: .default, reuseIdentifier: "Identity")
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ class UITableViewTests : RxTest {
|
|||
let createView: () -> (UITableView, Disposable) = {
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
tableView.register(NSClassFromString("UITableViewCell"), forCellReuseIdentifier: "a")
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithCellIdentifier("a")) { (index: Int, item: Int, cell) in
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items(cellIdentifier: "a")) { (index: Int, item: Int, cell) in
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -345,7 +345,7 @@ class UITableViewTests : RxTest {
|
|||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
tableView.register(NSClassFromString("UITableViewCell"), forCellReuseIdentifier: "a")
|
||||
let dataSource = SectionedViewDataSourceMock()
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_itemsWithDataSource(dataSource))
|
||||
let dataSourceSubscription = items.bindTo(tableView.rx_items(dataSource: dataSource))
|
||||
|
||||
return (tableView, dataSourceSubscription)
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ extension UITableViewTests {
|
|||
let items: Observable<[Int]> = Observable.just([1, 2, 3])
|
||||
let dataSource = SectionedViewDataSourceMock()
|
||||
let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: 1, height: 1))
|
||||
dataSourceSubscription = items.bindTo(tableView.rx_itemsWithDataSource(dataSource))
|
||||
dataSourceSubscription = items.bindTo(tableView.rx_items(dataSource: dataSource))
|
||||
|
||||
_ = dataSource.rx_deallocated.subscribeNext { _ in
|
||||
dataSourceDeallocated = true
|
||||
|
|
@ -392,7 +392,7 @@ extension UITableViewTests {
|
|||
|
||||
let items: Observable<[Int]> = Observable.just([1, 2, 3])
|
||||
let dataSource = SectionedViewDataSourceMock()
|
||||
_ = items.bindTo(tableView.rx_itemsWithDataSource(dataSource))
|
||||
_ = items.bindTo(tableView.rx_items(dataSource: dataSource))
|
||||
|
||||
_ = dataSource.rx_deallocated.subscribeNext { _ in
|
||||
dataSourceDeallocated = true
|
||||
|
|
|
|||
Loading…
Reference in New Issue