Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Factor cancel/completion handler dispatch out.

  • Loading branch information...
commit a2592fab67805150f1735dc2db8a866b39449de3 1 parent 1ac6a73
Rob Rix authored
Showing with 7 additions and 2 deletions.
  1. +7 −2 RXFutures/RXFuture.m
9 RXFutures/RXFuture.m
View
@@ -29,6 +29,11 @@ -(void)dealloc {
}
+-(void)dispatchBlock:(void(^)())block {
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
+}
+
+
-(void)onComplete:(void(^)())block {
dispatch_async(queue, ^{
[completionHandlers addObject:block];
@@ -47,7 +52,7 @@ -(void)cancel {
if(!cancelled && !completed) {
self.cancelled = YES;
for(void (^block)() in cancellationHandlers) {
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
+ [self dispatchBlock:block];
}
}
});
@@ -58,7 +63,7 @@ -(void)complete {
if(!cancelled && !completed) {
self.completed = YES;
for(void (^block)() in completionHandlers) {
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block);
+ [self dispatchBlock:block];
}
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.