-
-
Save tonyarnold/f1cd9a453e9bc1bea45d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[[[RACAble(self.eventManagedObjectID) distinctUntilChanged] map:^TBDMilestone *(NSManagedObjectID *nextEventManagedObjectID) { | |
@strongify(self); | |
if (TCBIsEmpty(nextEventManagedObjectID)) { | |
return nil; | |
} | |
NSError *objectRetrievalError; | |
TBDMilestone *milestone = (TBDMilestone *)[self.controllerManagedObjectContext existingObjectWithID:nextEventManagedObjectID error:&objectRetrievalError]; | |
if (TCBIsEmpty(milestone)) { | |
TCBLogError(objectRetrievalError); | |
} | |
return milestone; | |
}] deliverOn:[RACScheduler mainThreadScheduler]] subscribeNext:^(TBDMilestone *milestone) { | |
@strongify(self); | |
self.label = milestone.label; | |
self.photo = [UIImage imageWithData:milestone.photo.data]; | |
self.startDate = TCBIsNotEmpty(milestone) ? milestone.startedAt :[NSDate date]; | |
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RAC(self.milestone) = [[RACAble(self.eventManagedObjectID) distinctUntilChanged] map:^TBDMilestone *(NSManagedObjectID *nextEventManagedObjectID) { | |
@strongify(self); | |
if (TCBIsEmpty(nextEventManagedObjectID)) { | |
return nil; | |
} | |
NSError *objectRetrievalError; | |
TBDMilestone *milestone = (TBDMilestone *)[self.controllerManagedObjectContext existingObjectWithID:nextEventManagedObjectID error:&objectRetrievalError]; | |
if (TCBIsEmpty(milestone)) { | |
TCBLogError(objectRetrievalError); | |
} | |
return milestone; | |
}]; | |
[RACAbleWithStart(self.milestone) subscribeNext :^(TBDMilestone *nextMilestone) { | |
@strongify(self); | |
self.label = nextMilestone.label; | |
self.photo = [UIImage imageWithData:nextMilestone.photo.data]; | |
self.startDate = TCBIsNotEmpty(nextMilestone) ? nextMilestone.startedAt :[NSDate date]; | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment