mirror of
https://github.com/zhigang1992/FunctionalReactivePixels.git
synced 2026-01-12 22:47:31 +08:00
Abstracted away ableToVoteSignal.
This commit is contained in:
@@ -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];
|
||||
|
||||
|
||||
@@ -24,6 +24,5 @@
|
||||
@property (nonatomic, readonly) RACCommand *voteCommand;
|
||||
|
||||
@property (nonatomic, readonly) BOOL loggedIn;
|
||||
@property (nonatomic, readonly) RACSignal *ableToVoteSignal;
|
||||
|
||||
@end
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user