Binding to a table view with multiple cells and sections

One of the questions that keeps popping up in the RxSwift Slack channel for years now is how to display multiple cell types when binding data to a table view. This is actually very easy to do and in this post I’ll show you two distinct ways to display multiple cells in a table view (and it works identically for collection views if that’s what you’re looking for). We’ll look at the following two use cases:

Introducing RxAnimated

RxCocoa is super powerful for UI bindings - you can use bind(to:) to bind pretty much any kind of observable to a UI Control of your choice. You can bind a String to a UILabel, UIImage to a UIImageView, or an array of objects to UITableView or UICollectionView. Now, for table and collection view bindings there is a special library to allow you to bind a list of objects called RxDataSources and besides all the other goodness the library can add animations to your bindings.

Custom property bindings with RxSwift

Recently, in one of the few meetups I’ve been in person to, someone told me the didn’t try RxSwift because somebody told them that RxSwift doesn’t support custom views. While I’m still baffled what that original person meant, I thought the best way to disagree is to write a short tutorial to prove them wrong. What are custom property sinks? When you use RxCocoa bindings you can easily bind the values an observable emits to some view on screen like so: