Create a gist now

Instantly share code, notes, and snippets.

@tonyarnold /new.m Secret
Created Apr 25, 2013

What would you like to do?
[[[[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];
}];
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