Skip to content

Instantly share code, notes, and snippets.

@tonyarnold

tonyarnold/new.m Secret

Created April 25, 2013 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tonyarnold/f1cd9a453e9bc1bea45d to your computer and use it in GitHub Desktop.
Save tonyarnold/f1cd9a453e9bc1bea45d to your computer and use it in GitHub Desktop.
[[[[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