Now that there's a full support for KVO, has anybody made a mutable table view that takes a RACSignal as its dataSource? Ideally something that doesn't require any configuration.
RACSignal *commentsSignal;
UITableView *table = [UITableView new];
table.dataSourceSignal = commentsSignal;
[self.view addSubview:table];
// No more basic config
ReactiveCocoa 3.0 (currently in development) adds a category on UITableView that does just that.
I haven't updated it in a couple weeks, but I made an early podspec for it: https://gist.github.com/adlai-holler/ae321c3398d7db9a55c0
Yes, I have created a 'binding helper' that binds a table view to a signal:
http://www.scottlogic.com/blog/2014/05/11/reactivecocoa-tableview-binding.html
You can use it to bind a signal to table view where the cell is defined in a nib, as shown below:
// create a cell template
UINib *nib = [UINib nibWithNibName:@"CETweetTableViewCell" bundle:nil];
// bind the ViewModels 'searchResults' property to a table view
[CETableViewBindingHelper bindingHelperForTableView:self.searchResultsTable
sourceSignal:RACObserve(self.viewModel, searchResults)
templateCell:nib];
In the above example the table view is bond to an NSArray
property on a view model via RACObserve(self.viewModel, searchResults)
, however any RACSignal
that emits an array will bind just fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With