BoltsFramework/Bolts-iOS — pull request #21 by ide (2014-02-27 07:50:25+00:00)
Title: +[BFTask taskFromExecutor:withBlock] to easily create ad-hoc tasks

This convenience class method makes it easier to create tasks from blocks
without needing to write the code for a temporary `BFTask` or
`BFTaskCompletionSource`. Usage:

[[BFTask taskFromExecutor:executor withBlock:id ^{
return work_on_queue();
}] continueWithBlock:...];

As opposed to:

BFTaskCompletionSource *tcs = [BFTaskCompletionSource taskCompletionSource];
dispatch_async(queue, ^{
[tcs setResult:work_on_queue()];
});
[tcs.task continueWithBlock:...];

The convenience method also handles exceptions the same way the rest of BFTasks
does so that's another plus.

Test case is included.