Rxswift: Question: reactive tableView delegate callbacks?

Created on 19 Apr 2016  路  3Comments  路  Source: ReactiveX/RxSwift

I'm playing with ReactiveDataSource and data-part looks very good, however I have different height (depends on model) for every cell. What is the most idiomatic way to reactify heightForRowAtIndexPath if it is possible at all?

Currently I'm caching returned models in viewController using doOn for side effects

Most helpful comment

Hello,@garnett and @kzaher . I also have the same question about how to get different height for every tableViewCell. I have read about CustomizationUsingTableViewDelegate example. But I only known I need to use setDelegate to set table view delegate to my VC ,and then I can use the delegate methods to get the height:

     func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
              return 50
      }

but how can I get different height? If I need to get a model in here,and calculate the height of the content? Or, there are some other good ways? Please let me known, Thanks.

All 3 comments

Hi @garnett ,

I've updated example app in RxDataSources.

Take a look at CustomizationUsingTableViewDelegate.

You can just use rx_setDelegate to set table view delegate to your VC or some other data source where you have your lambda.

You can always inherit one of data sources and make it implement UITableViewDelegate methods and add your own closures that implement those methods. There is no reason why data source couldn't also implement delegate methods since you can observe notifications using RxCocoa extensions.

@kzaher that's exactly what I was looking for, thanks!

Hello,@garnett and @kzaher . I also have the same question about how to get different height for every tableViewCell. I have read about CustomizationUsingTableViewDelegate example. But I only known I need to use setDelegate to set table view delegate to my VC ,and then I can use the delegate methods to get the height:

     func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
              return 50
      }

but how can I get different height? If I need to get a model in here,and calculate the height of the content? Or, there are some other good ways? Please let me known, Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gregpardo picture gregpardo  路  4Comments

apoloa picture apoloa  路  3Comments

trungp picture trungp  路  3Comments

Z-JaDe picture Z-JaDe  路  3Comments

lyricsboy picture lyricsboy  路  3Comments