Is there a way that i could call a Async Method in a loop, put all the results in a array & return the results in the end.
Pseudo Code of what i want to do:
methodThatRunsAsync(callback){
once completes, invoke callback;
}
anotherMethod (){
var result = [];
for(i=1; i=10; i++){methodThatRunsAsync(function(resp){ result.push(resp); }); return result; }}
But the value of result is always the default value. How can i trap the results of the async block in a sync block and return the same to the caller.
Looking into Promise framework, but finding it a bit tough to get my head around it. If anyone can please help me understand how to achieve this, psuedo code too would be great.