Allow setting the result of a task completion source from an existing task.
Created by: richardjrossiii
Frequently, I have to write code like this:
BFTaskCompletionSource *source = [BFTaskCompletionSource taskCompletionSource];
[.... continueWithBlock:^id(BFTask *task) {
if (task.faulted) {
NSError *error = task.error;
if (error) {
[source trySetError:error];
} else {
[source trySetException:task.exception];
}
} else if (task.cancelled) {
[source trySetCancelled];
} else {
[source trySetResult:task.result];
}
return task;
}];
It would be nice if there was an API similar to [source trySetTask:task]
instead of having this ugly block of code.