-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a #1
Comments
I'm working on an app which has an "infinite scrolling" UICollectionView with a couple of cells per section. Some of the cells have a button which will in turn cause insertions or deletions from the CV and will fire of network requests. What I'm trying to do is to make the viewModel subscribe to signals from the button action in the cell which will fire off a network request and then forward the signal to the controller so it can update it's CV. What I'm doing right now is this: CustomCollectionViewCell.h @property (strong, nonatomic) RACSignal *clickedButtonSignal; CustomCollectionViewCell.m - (IBAction)buttonClicked {
// Already initialized the clickedButtonSignal elsewhere
[(RACSubject *)self.clickedButtonSignal sendNext:self.indexPath];
} CollectionViewDataSource.m - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
// Dequeue cell
cell.clickedButtonSignal = self.viewModel.clickedButtonSignal;
} ViewModel.h @property (strong, nonatomic) RACSignal *clickedButtonSignal;
@property (strong, nonatomic) RACSignal *insertSectionsSignal; ViewModel.m - (id)init {
// Doing stuff
[self.clickedButtonSignal subscribeNext:^(NSIndexPath *indexPath) {
// Get the correct item and make a network request
// The controller subscribes to this signal and updates the CV respectively
[(RACSubject *)self.insertSectionsSignal sendNext:[NSValue valueWithRange:NSMakeRange()];
}];
} So basically each CVCell has a reference to the clickedButtonSignal in the viewModel (which just doesn't seem right). My other idea was that the clickedButtonSignal in the cells would would use rac_signalForSelector: and then the viewModel would observe all those signal but with maybe 150 cells in the CV I started thinking that could be bad performance wise. Right now my solution is working but like I said it just doesn't seem right. I'd be very greatful if anyone could comment on my solution so far or give me any ideas on how I could implement this. Thanks in advance! |
No description provided.
The text was updated successfully, but these errors were encountered: