0

I am trying to bind single UITableView with 2 data sources. My code is like this

viewModel?.dataSource?.currentYear?.bind(to: tableViewMonths, cellType: StatementExportMonthTableViewCell.self) { (cell, name) in
            cell.updateWith(month: name)
        }

viewModel?.dataSource?.previousYear?.bind(to: tableViewMonths, cellType: StatementExportMonthTableViewCell.self) { (cell, name) in
            cell.updateWith(month: name)
        }

I cant figure out how to show correct data into table view based on selected segment index. I know i can define one main data source and based on segment selection I should assign respective data source to that instance and reload tableview from that.

But I am trying to simplify it if Bond already has that functionality in-built.

Any help here would be much appreciated.

Thanks

Paras Gorasiya
  • 1,295
  • 2
  • 13
  • 33
  • This looks like it would be simpler to do if you merged the two data sources into one and used it that way. – Adis Feb 10 '20 at 14:09
  • Thats what I am doing currently but I am curious if it can be achieved without using a separate data source and reloading the table accordingly. – Paras Gorasiya Feb 10 '20 at 14:57
  • Even if you could, doing so is against the reactive paradigm. Your reactive code should be output centric. – Daniel T. Feb 10 '20 at 15:43

0 Answers0