robrix/RXFutures — Issue #1: Call the -onCancel:/-onComplete: block immediately when already cancelled/completed
Author: robrix
Created: 2011-11-28 22:09:48+00:00
State: open

This will avoid a race condition:

RXFuture *future = [something workWithCompletionHandler:^{ … }];
[future onCancel:^{ … }];

If the future has already been cancelled by the time -onCancel: is called, then the block is never called.

Same thing goes for completion handlers that are added to the future after it’s been returned.