1

This is what I need to do:

function myFunc(ID, callback){
    func1("foo", res => { console.log(res) });
    func2("bar", res => { console.log(res) });
    func3("batz", res => { console.log(res) });

    // Here I need to call callback(something); when all of
    // the above funcs terminated and called their callbacks.

    // I could increment/decrement a counter to know how many
    // callbacks executed, but then how could I execute a function
    // (e.g. a callback) as soon as this counter gets to 0 ?
}

I need a smart and clean solution if possible (because I already find the counter trick being a work-around) :)

Thanks !!

Morgan Le Floc'h
  • 314
  • 2
  • 4
  • 12

0 Answers0