Skip to content
Snippets Groups Projects
Commit 1186a3cb authored by Dariusz Rybicki's avatar Dariusz Rybicki
Browse files

Refactor

parent 9d77239c
No related branches found
No related tags found
2 merge requests!54Releasing 1.1.4,!51CollectionView library
......@@ -2,6 +2,10 @@ import UIKit
public struct CellFactory<Model> {
public struct Registrar {
public init(register: @escaping (UICollectionView) -> Void) {
self.register = register
}
public var register: (UICollectionView) -> Void
public func callAsFunction(in view: UICollectionView) {
......@@ -10,20 +14,21 @@ public struct CellFactory<Model> {
}
public struct Builder {
public var buildCell: (Model, UICollectionView, IndexPath) -> UICollectionViewCell?
public init(build: @escaping (Model, UICollectionView, IndexPath) -> UICollectionViewCell?) {
self.build = build
}
public var build: (Model, UICollectionView, IndexPath) -> UICollectionViewCell?
public func callAsFunction(
for model: Model,
in view: UICollectionView,
at indexPath: IndexPath
) -> UICollectionViewCell? {
buildCell(model, view, indexPath)
build(model, view, indexPath)
}
}
public var register: Registrar
public var build: Builder
public init(
register: Registrar,
build: Builder
......@@ -31,6 +36,9 @@ public struct CellFactory<Model> {
self.register = register
self.build = build
}
public var register: Registrar
public var build: Builder
}
extension CellFactory {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment