I have a base async function that returns a Promise
function asyncFoo(): Promise<void> {
  return new Promise<void>((resolve, reject) => {
    // I'm using here a setTimeout to fake async flow, in reality I'm making a server call
    setTimeout(() => {
      resolve();
    }, 5000);
  });
}
I can use my method
const promise = asyncFoo();
promise.then(() => {
  console.log('Hello');
});
However if I debounce my function, the result function doesn't return anything, and I can't wait for it to resolve
const debounceFoo = _.debounce(asyncFoo, 100);
debounceFoo(); // undefined
// I would like to do something like
// debounceFoo().then(...) this will not work
How can I debounce the events (aggregate them) that happen during the debounce-time, then execute my asyncFoo(). And finally, act on its resolve callback?
 
     
    