In application I am writing I decided to use MVVM patter. I am binding ViewModels with Views using RxSwift + RxCocoa. Now I am facing a problem I cannot find any solution myself.
I have a list of ViewModels which I want to display in UITableView. In tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)
method I am dequeueing a cell and I am binding one of ViewModels from the list to this cell. ViewModel has imageUrl
Variable and I use Kingfisher to download this image and put it into ImageView in that cell.
So here is my problem now: when download is completed I have to reload this row so Auto Layout will calculate its correct height. But when I use tableView.reloadRows(at: [indexPath], with: .none)
the binding is recreated and it ends up with infinite loop (binding -> image download completion callback -> reload row -> binding -> ...)!
Any ideas how to workaround this?