Coming from JavaScript world using async javascript promises, and I believe the same is done using GCD async queues in Swift.

Can you point me to an example where 2 to 3 async functions are specified in a queue, with one async operation feeding the result to the second, and second feeding the result to the third (commonly known as piping the results) and then finally a result and error handler.

Edit. Also learned from the example that steps are more like a manual linear path in GCD where developer is the one feeding result to the next and checking error each time, Any Functional Programming possible using Function Compositions?

I want to avoid Pyramid of Doom and looking for a linear async programming.

2 Solutions Collect From Internet About “GCD pattern for chaining async operations while piping the results”

I’ve reached out to Apple with a support request and they referred me to this WWDC15 video Advance NSOperations.

I didn’t get to see how to pipe results from one sub operation to the other, now based on this video if someone can write some comprehensive example code where one routine after executing passing results to the next, I’d accept the answer.

There is no support for that in the standard library and there probably won’t be for a while. There are great third-party libraries, but if you don’t want those, you could define a minimum yourself (I’m using Swift 3 here):