Today I’ve been asked on how approach the creation of a sequence of async calls and retain control over any possible point of failure.
There are several possible solutions to this scenario, using es2016’s async functions or es2015’s generator functions would make the solution simpler and easier to be read but I’ve been asked to use only valid es5 code.
The goals of this particular exercise are:
- accept sequences of variable length
- create a reusable solution
- have knowledge and control over thrown exceptions
The basic idea is to create an array of async actions and execute it step by step. To support this we need an object able to iterate over our array of actions.