HackerNewsReaderDemo
HackerNewsAPI.sharedApi.newStories() .observeOn(ConcurrentDispatchQueueScheduler.init(globalConcurrentQueueQOS: .Background)) .map { $0.dropLast($0.count - 15).map { HackerNewsAPI.sharedApi.item($0) } } .map { $0.zip({ $0 }) } .switchLatest() .map { $0.map { ItemViewModel(item: $0) } } .observeOn(MainScheduler.instance) .doOnNext { [unowned self] _ in self.endUpdateTableView() } .doOnError { [unowned self] _ in self.endUpdateTableView() } .bindTo(tableView.rx_itemsWithCellIdentifier("ItemTableViewCell", cellType: ItemTableViewCell.self)) { (row, item, cell) in cell.viewModel = item }.addDisposableTo(disposeBag)
时间: 2024-11-07 02:01:20