From 1186a3cbaea9d107e5fab13fd875afe6e3877f6f Mon Sep 17 00:00:00 2001 From: Dariusz Rybicki <dariusz@elixxir.io> Date: Mon, 18 Jul 2022 13:08:10 +0100 Subject: [PATCH] Refactor --- Sources/CollectionView/CellFactory.swift | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sources/CollectionView/CellFactory.swift b/Sources/CollectionView/CellFactory.swift index 00faf2c2..10f46371 100644 --- a/Sources/CollectionView/CellFactory.swift +++ b/Sources/CollectionView/CellFactory.swift @@ -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 { -- GitLab