public func items<Sequence: Swift.Sequence, Cell: UICollectionViewCell, Source: ObservableType>
(cellIdentifier: String, cellType: Cell.Type = Cell.self)
-> (_ source: Source)
-> (_ configureCell: @escaping (Int, Sequence.Element, Cell) -> Void)
-> Disposable where Source.Element == Sequence {
return { source in
return { configureCell in
let dataSource = RxCollectionViewReactiveArrayDataSourceSequenceWrapper<Sequence> { 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.items(dataSource: dataSource)(source)
}
}
}
函数返回值拆解
参数:(cellIdentifier: String, cellType: Cell.Type = Cell.self)
返回值是一个闭包,该闭包的返回值还是一个闭包。
第一个闭包的参数是 source,返回值是 ((_ configureCell: @escaping (Int, Sequence.Element, Cell) -> Void) -> Disposable)
第二个闭包的参数是一个闭包 (_ configureCell: @escaping (Int, Sequence.Element, Cell) -> Void),返回值是 Disposable