Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Duplicate item ... #353

Open
nickfl opened this issue Jan 22, 2020 · 1 comment
Open

Fatal error: Duplicate item ... #353

nickfl opened this issue Jan 22, 2020 · 1 comment

Comments

@nickfl
Copy link

nickfl commented Jan 22, 2020

Log shows first:

Item <HD_Rx.TrackItemPresentable: 0x6000034ab980> has already been indexed at (0, 33)
Fatal error: Duplicate item <HD_Rx.TrackItemPresentable: 0x6000034ab980>: file
..../Pods/RxDataSources/Sources/RxDataSources/DataSources.swift, line 32

Where TrackItemPresentable is part of
TrackSection = AnimatableSectionModel<String, TrackItemPresentable>

Binding is done standard way:

    viewModel.sectionedItems
      .bind(to: tableView.rx.items(dataSource: dataSource))
      .disposed(by: self.rx.disposeBag)

where var sectionedItems: Observable<[TrackSection]>

And app crashes on the next update of sectionedItems.

@nickfl
Copy link
Author

nickfl commented Jan 22, 2020

OK, I kinda fixed it.
The problem was in dataSource:
.bind(to: tableView.rx.items(dataSource: dataSource))

as looks like dataSource keeps all previous data.
Maybe there is a method to flush it, but I couldn't find it.

So, I got rid of it and used a more direct binding on the go:

 .bind(to: tableView.rx.items(cellIdentifier: ResultTableViewCell.reuseId)) { row, model, cell in
     (cell as ResultTableViewCell).configureCell(track: model)
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant