import TISwiftUtils import Foundation open class DefaultCollectionViewModel { public typealias SelectItemHandlerPayload = (itemViewModel: ItemViewModel, indexPath: IndexPath) public var items: [ItemViewModel] public var selectItemHandler: ParameterClosure? public init(items: [ItemViewModel], selectItemHandler: ParameterClosure? = nil) { self.items = items self.selectItemHandler = selectItemHandler } open func numberOfSections() -> Int { 1 } open func numberOfItems(inSection section: Int) -> Int { items.count } open func itemViewModel(at indexPath: IndexPath) -> ItemViewModel { items[indexPath.row] } open func didSelectItem(at indexPath: IndexPath) { selectItemHandler?(SelectItemHandlerPayload(itemViewModel(at: indexPath), indexPath)) } }