Abstracted away ableToVoteSignal.

This commit is contained in:
Ash Furrow
2013-10-24 13:32:49 -04:00
parent ee9a2316ca
commit fe72ba3801
3 changed files with 2 additions and 8 deletions

View File

@@ -87,7 +87,7 @@
[RACObserve(self.viewModel, voteButtonText) subscribeNext:^(id value) {
[voteButton setTitle:value forState:UIControlStateNormal];
}];
voteButton.rac_command = [[RACCommand alloc] initWithEnabled:self.viewModel.ableToVoteSignal signalBlock:^RACSignal *(id input) {
voteButton.rac_command = [[RACCommand alloc] initWithEnabled:self.viewModel.voteCommand.enabled signalBlock:^RACSignal *(id input) {
// Assume that we're logged in at first. We'll replace this signal later if not.
RACSignal *authSignal = [RACSignal empty];

View File

@@ -24,6 +24,5 @@
@property (nonatomic, readonly) RACCommand *voteCommand;
@property (nonatomic, readonly) BOOL loggedIn;
@property (nonatomic, readonly) RACSignal *ableToVoteSignal;
@end

View File

@@ -25,8 +25,6 @@
@property (nonatomic, strong) RACCommand *voteCommand;
@property (nonatomic, strong) RACSignal *ableToVoteSignal;
@end
@implementation FRPPhotoDetailViewModel
@@ -51,14 +49,11 @@
}];
@weakify(self);
self.voteCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
self.voteCommand = [[RACCommand alloc] initWithEnabled:[RACObserve(self.photoModel, votedFor) not] signalBlock:^RACSignal *(id input) {
@strongify(self);
return [FRPPhotoImporter voteForPhoto:self.photoModel];
}];
self.ableToVoteSignal = [RACObserve(self.photoModel, votedFor) not];
return self;
}