UICollectionView+Rx.swift 505 B

1234567891011121314151617181920
  1. //
  2. // UICollectionView+Rx.swift
  3. // SwiftBilibili
  4. //
  5. // Created by 罗文 on 2021/1/20.
  6. // Copyright © 2021年 罗文. All rights reserved.
  7. //
  8. import RxCocoa
  9. import RxDataSources
  10. import RxSwift
  11. extension Reactive where Base: UICollectionView {
  12. func itemSelected<S>(dataSource: CollectionViewSectionedDataSource<S>) -> ControlEvent<S.Item> {
  13. let source = self.itemSelected.map { indexPath in
  14. dataSource[indexPath]
  15. }
  16. return ControlEvent(events: source)
  17. }
  18. }