Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Futures can pass control to other futures.

This is ideally used as sort of a tail call.
  • Loading branch information...
commit 6a17ea569efd9f8f46567cfb46504408ada48a4e 1 parent 161bb79
@robrix authored
Showing with 10 additions and 0 deletions.
  1. +1 −0  RXFutures/RXFuture.h
  2. +9 −0 RXFutures/RXFuture.m
View
1  RXFutures/RXFuture.h
@@ -34,5 +34,6 @@
@property (nonatomic, readonly, assign, getter=isCompleted) BOOL completed;
-(void)cascadeCancellationToFuture:(RXFuture *)future; // cancels the argument when the receiver is cancelled
+-(void)passControlToFuture:(RXFuture *)future; // cancels the argument when the receiver is cancelled; cancels the receiver when the argument is cancelled; completes the receiver when the argument is completed
@end
View
9 RXFutures/RXFuture.m
@@ -122,4 +122,13 @@ -(void)cascadeCancellationToFuture:(RXFuture *)future {
[self onCancel:^{ [future cancel]; }];
}
+-(void)passControlToFuture:(RXFuture *)future {
+ if (future)
+ {
+ [self onCancel:^{ [future cancel]; }];
+ [future onCancel:^{ [self cancel]; }];
+ [future onComplete:^{ [self complete]; }];
+ }
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.