ColinEberhardt / ReactiveTwitterSearch

A ReactiveCocoa 4.0 MVVM example
MIT License
215 stars 27 forks source link

Fetching avatar and assigning to UIImageView #20

Open badeleux opened 8 years ago

badeleux commented 8 years ago

Hey,

I was going through your code and I am not sure about the binding code in cell:

Fetching avatar is asynchronous, so IMO there might be a situation where you initiated download for the user1 and it took unusually long to fetch, than user scrolled and this cell started fetching avatar for user10 which was cached but after some time device got response from first request, in result - cell will show avatar for user1

What I usually do is I create one ViewModel for One Cell (1 to 1 relationship) and I bind this two objects and in dataSource method I update viewModel properties which in turn update cell properties using .Latest strategy.

Another thing which I am worried about is that Views/TableViewCells should be dead simple. Invoking any IO code in View abuses this architecture.