Added loading property to FRPPhotoViewModel.

This commit is contained in:
Ash Furrow
2013-12-28 09:40:25 -05:00
parent ced77bc04d
commit 4a87330f0e
3 changed files with 13 additions and 5 deletions

View File

@@ -51,11 +51,12 @@
[self.view addSubview:imageView];
self.imageView = imageView;
[[self.viewModel.didBecomeActiveSignal take:1] subscribeCompleted:^{
[SVProgressHUD show];
}];
[RACObserve(self.viewModel, photoImage) subscribeNext:^(id _){
[SVProgressHUD dismiss];
[RACObserve(self.viewModel, loading) subscribeNext:^(NSNumber *loading){
if (loading.boolValue) {
[SVProgressHUD show];
} else {
[SVProgressHUD dismiss];
}
}];
}

View File

@@ -15,6 +15,7 @@
@property (nonatomic, readonly) FRPPhotoModel *model;
@property (nonatomic, readonly) UIImage *photoImage;
@property (nonatomic, readonly, getter = isLoading) BOOL loading;
-(NSString *)photoName;

View File

@@ -15,6 +15,7 @@
@interface FRPPhotoViewModel ()
@property (nonatomic, strong) UIImage *photoImage;
@property (nonatomic, assign, getter = isLoading) BOOL loading;
@end
@@ -46,9 +47,14 @@
#pragma mark - Private Methods
-(void)downloadPhotoModelDetails {
self.loading = YES;
@weakify(self);
[[FRPPhotoImporter fetchPhotoDetails:self.model] subscribeError:^(NSError *error) {
NSLog(@"Could not fetch photo details: %@", error);
} completed:^{
@strongify(self);
self.loading = NO;
NSLog(@"Fetched photo details.");
}];
}