I have 2 simple methods:
function do(x,y){
if(x){
XHR1().success();
}
if(y){
XHR2().success();
}
}
function done(){
return something;
}
now i just would like to be sure to call done()
when do()
has finished (**do() method contains async requests to Mysql DB)
how can i achieve this?**
Obviously this won't put such methods in sequence:
do(x=1,y=1);
done(); //this can run also if do() has not finished yet
So i tryed:
function do(x,y,_callback){
if(x){
XHR1().success();
}
if(y){
XHR2().success();
}
_callback();
}
function done(){
return something;
}
do(x=1,y=1,done()); // this won't work the same cause callback is not dependent by XHR response
this is what i use for promises https://github.com/tildeio/rsvp.js/#arrays-of-promises