mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-01-12 22:47:31 +08:00
Added loading property to FRPPhotoViewModel.
This commit is contained in:
@@ -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];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
@property (nonatomic, readonly) FRPPhotoModel *model;
|
||||
|
||||
@property (nonatomic, readonly) UIImage *photoImage;
|
||||
@property (nonatomic, readonly, getter = isLoading) BOOL loading;
|
||||
|
||||
-(NSString *)photoName;
|
||||
|
||||
|
||||
@@ -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.");
|
||||
}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user