No more JQuery Deferred for me. From know on I'm using a Promise Library that allows me more powerful operations like chaining and combinations.
In this post I'm focusing on array operations like:
- Execute multiple functions and execute something after all of these have finished
- Map() implementation using async functions (aka: qMap)
Each of the points above are available on jsFiddle for you to tweak...
Using Q.all we can achieve this easily. Just take a peak at the following jsFiddle.
To execute a async functions in sequence over an array of items the qMap function was created. The signature of this is the same as the map() but the difference is that each function return a Q.promise to sync the execution.
Unfortunately I could not find any other way, using Q, to achieve this sync execution so I've written the qMap function. If you find any other way to write this please let me know.