RxTableViewSectionedReloadDataSource.swift 845 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // RxTableViewSectionedReloadDataSource.swift
  3. // RxExample
  4. //
  5. // Created by Krunoslav Zaher on 6/27/15.
  6. // Copyright © 2015 Krunoslav Zaher. All rights reserved.
  7. //
  8. #if os(iOS) || os(tvOS)
  9. import Foundation
  10. import UIKit
  11. #if !RX_NO_MODULE
  12. import RxSwift
  13. import RxCocoa
  14. #endif
  15. import Differentiator
  16. open class RxTableViewSectionedReloadDataSource<Section: SectionModelType>
  17. : TableViewSectionedDataSource<Section>
  18. , RxTableViewDataSourceType {
  19. public typealias Element = [Section]
  20. open func tableView(_ tableView: UITableView, observedEvent: Event<Element>) {
  21. Binder(self) { dataSource, element in
  22. #if DEBUG
  23. dataSource._dataSourceBound = true
  24. #endif
  25. dataSource.setSections(element)
  26. tableView.reloadData()
  27. }.on(observedEvent)
  28. }
  29. }
  30. #endif