RxSwiftCommunity / RxDataSources

UITableView and UICollectionView Data Sources for RxSwift (sections, animated updates, editing ...)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RxTableViewSectionedAnimatedDataSource dataSource sectionModels are always same with newSections

arpitdsoni opened this issue · comments

I have been debugging an issue where cell viewModel gets updated but cell reloading doesn't happen until user manually scrolls cell off screen.

I have verified that IdentifiableType and Equatable are implemented correctly and cellModel properties do get updated, however oldSections and newSections in tableView(_ tableView: UITableView, observedEvent: Event<Element>) are always same, because of this lhs and rhs are always same for all items. I don't understand how dataSource.sectionModels are updated before even diff happens

Observable.combineLatest inside getDashboardItemsAsObservable() to create AnimatableSectionModel(model: "some", items: cellViewModels)

viewModel.getDashboardItemsAsObservable()
  .asDriver(onErrorJustReturn: [])
  .debug()
  .do(onNext: { [weak self] (sectionModel) in
     //
  })
  .drive(tableView.rx.items(dataSource: viewModel.dataSource))
  .disposed(by: disposeBag)

Any help is appreciated!

i meet the same problem,how did you resolve it?

I probably know the reason. It may be that after the viewmodel is updated, it is still the previous viewmodel without creating a new viewmodel, resulting in Equatable being always consistent.