ReactiveX / RxSwift

Reactive Programming in Swift
MIT License
24.36k stars 4.17k forks source link

Question: reactive tableView delegate callbacks? #629

Closed delebedev closed 8 years ago

delebedev commented 8 years ago

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

kzaher commented 8 years ago

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.

delebedev commented 8 years ago

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

longshihua commented 7 years ago

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.