If either fails, the other request is cancelled and the failure result is passed to the completion handler. A new Cancelable protocol allows cancelable things to be composed together (e.g., dispatch blocks and URL session tasks).
I plan to add some tests for the basic behaviours, especially around how cancellation is handled. I honestly am not sure how to write a test for the thread-safety aspects of this code, but I'm pretty sure all reads and writes to the combined state are appropriately synchronised. I'll do another review to make sure there's no race between updating the combined state and waiting on the request group to complete.
Adds a new extension to the
Client
protocol that allows two requests to be performed concurrently, with their results combined into a tuple:If either fails, the other request is cancelled and the failure result is passed to the completion handler. A new
Cancelable
protocol allows cancelable things to be composed together (e.g., dispatch blocks and URL session tasks).I plan to add some tests for the basic behaviours, especially around how cancellation is handled. I honestly am not sure how to write a test for the thread-safety aspects of this code, but I'm pretty sure all reads and writes to the combined state are appropriately synchronised. I'll do another review to make sure there's no race between updating the combined state and waiting on the request group to complete.