Skip to content

Commit 82500a2

Browse files
committed
opening up init(cellFactory)
1 parent 68c0680 commit 82500a2

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

Sources/CombineDataSources/CollectionView/CollectionViewItemsController.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,23 @@ public class CollectionViewItemsController<CollectionType>: NSObject, UICollecti
3333
public var dataSource: UICollectionViewDataSource?
3434

3535
// MARK: - Init
36+
37+
/// An initializer that takes a cell type and identifier and configures the controller to dequeue cells
38+
/// with that data and configures each cell by calling the developer provided `cellConfig()`.
39+
/// - Parameter cellIdentifier: A cell identifier to use to dequeue cells from the source collection view
40+
/// - Parameter cellType: A type to cast dequeued cells as
41+
/// - Parameter cellConfig: A closure to call before displaying each cell
3642
public init<CellType>(cellIdentifier: String, cellType: CellType.Type, cellConfig: @escaping CellConfig<Element, CellType>) where CellType: UICollectionViewCell {
3743
cellFactory = { dataSource, collectionView, indexPath, value in
3844
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellIdentifier, for: indexPath) as! CellType
3945
cellConfig(cell, indexPath, value)
4046
return cell
4147
}
4248
}
43-
44-
private init(cellFactory: @escaping CellFactory<Element>) {
49+
50+
/// An initializer that takes a closure expected to return a dequeued cell ready to be displayed in the collection view.
51+
/// - Parameter cellFactory: A `(CollectionViewItemsController<CollectionType>, UICollectionView, IndexPath, Element) -> UICollectionViewCell` closure. Use the table input parameter to dequeue a cell and configure it with the `Element`'s data
52+
public init(cellFactory: @escaping CellFactory<Element>) {
4553
self.cellFactory = cellFactory
4654
}
4755

Sources/CombineDataSources/TableView/TableViewItemsController.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public class TableViewItemsController<CollectionType>: NSObject, UITableViewData
4040
public var dataSource: UITableViewDataSource?
4141

4242
// MARK: - Init
43+
44+
/// An initializer that takes a cell type and identifier and configures the controller to dequeue cells
45+
/// with that data and configures each cell by calling the developer provided `cellConfig()`.
46+
/// - Parameter cellIdentifier: A cell identifier to use to dequeue cells from the source table view
47+
/// - Parameter cellType: A type to cast dequeued cells as
48+
/// - Parameter cellConfig: A closure to call before displaying each cell
4349
public init<CellType>(cellIdentifier: String, cellType: CellType.Type, cellConfig: @escaping CellConfig<Element, CellType>) where CellType: UITableViewCell {
4450
cellFactory = { dataSource, tableView, indexPath, value in
4551
let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! CellType
@@ -48,7 +54,10 @@ public class TableViewItemsController<CollectionType>: NSObject, UITableViewData
4854
}
4955
}
5056

51-
private init(cellFactory: @escaping CellFactory<Element>) {
57+
58+
/// An initializer that takes a closure expected to return a dequeued cell ready to be displayed in the table view.
59+
/// - Parameter cellFactory: A `(TableViewItemsController<CollectionType>, UITableView, IndexPath, Element) -> UITableViewCell` closure. Use the table input parameter to dequeue a cell and configure it with the `Element`'s data
60+
public init(cellFactory: @escaping CellFactory<Element>) {
5261
self.cellFactory = cellFactory
5362
}
5463

0 commit comments

Comments
 (0)