RX items方法拆解

    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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容