javascript: execute a bunch of asynchronous method with one callback
Posted
by Samuel Michelot
on Stack Overflow
See other posts from Stack Overflow
or by Samuel Michelot
Published on 2010-05-26T09:52:30Z
Indexed on
2010/05/26
11:11 UTC
Read the original article
Hit count: 285
I need to execute a bunch of asynchronous methods (client SQLite database), and call only one final callback.
Of course, the ugly way is:
execAll : function(callBack) {
asynch1(function() {
asynch2(function() {
...
asynchN(function() {
callBack();
})
})
});
}
But I know there are better ways to do it. Intuitively I would detect when all call back has been called with a counter to call the final callback.
I think this is a common design-pattern, so if someone could point me in the right direction...
Thanks in advance !
© Stack Overflow or respective owner