mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-01-12 22:47:31 +08:00
Merge remote-tracking branch 'origin/master' into broken
Conflicts: FRP/FRPGalleryViewController.m
This commit is contained in:
@@ -49,10 +49,15 @@ static NSString *CellIdentifier = @"Cell";
|
||||
[self.collectionView registerClass:[FRPCell class] forCellWithReuseIdentifier:CellIdentifier];
|
||||
|
||||
// Reactive Stuff
|
||||
RACSignal *photoSignal = [FRPPhotoImporter importPhotos];
|
||||
RACSignal *noErrors = [photoSignal catch:^RACSignal *(NSError *error) {
|
||||
NSLog(@"Couldn't fetch photos from 500px: %@", error);
|
||||
return [RACSignal empty];
|
||||
}];
|
||||
RACSignal *photosLoaded = RAC(self, photosArray) = noErrors;
|
||||
@weakify(self);
|
||||
[RACObserve(self, photosArray) subscribeNext:^(id x) {
|
||||
@strongify(self);
|
||||
|
||||
[photosLoaded subscribeCompleted:^{
|
||||
@strongify(self)
|
||||
[self.collectionView reloadData];
|
||||
}];
|
||||
|
||||
@@ -71,19 +76,6 @@ static NSString *CellIdentifier = @"Cell";
|
||||
[self.navigationController pushViewController:viewController animated:YES];
|
||||
}];
|
||||
self.collectionView.delegate = (id<UICollectionViewDelegate>)collectionViewDelegate;
|
||||
|
||||
// Load data
|
||||
[self loadPopularPhotos];
|
||||
}
|
||||
|
||||
#pragma mark - Private Methods
|
||||
|
||||
-(void)loadPopularPhotos {
|
||||
[[FRPPhotoImporter importPhotos] subscribeNext:^(id x) {
|
||||
self.photosArray = x;
|
||||
} error:^(NSError *error) {
|
||||
NSLog(@"Couldn't fetch photos from 500px: %@", error);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - UICollectionViewDataSource Methods
|
||||
|
||||
@@ -3,9 +3,9 @@ FunctionalReactivePixels
|
||||
|
||||
A demonstration of how to use FRP with ReactiveCocoa in an iOS context using the 500px API.
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
Nothing too complicated yet. Next step is a login and vote mechanic to demonstrate more use of `RACSubject` and `RACCommand`. Then I think it'll be done.
|
||||
|
||||
@@ -13,4 +13,4 @@ Please don't go all creepy with my consumer key.
|
||||
|
||||
Installing
|
||||
----------------
|
||||
Clone the repo and run `pod install` from the repo's directory to install the required pods.
|
||||
Clone the repo and run `pod install` from the repo's directory to install the required pods. Or if you don't like Cocoapods, just [download the zip](http://cloud.ashfurrow.com/013J0y1R3L2l).
|
||||
|
||||
Reference in New Issue
Block a user