I've found that I can't call async
functions with $.proxy
. My case was that I proxied event listeners so that they'd still have the same context, but as soon as I tried proxying to an async
function, it just didn't get called - also, no errors were thrown.
Could anyone explain me why this doesn't work?
The simple example below will allow you to reproduce the issue. When the async
keyword is there, the function will not be called. When you remove async
, it'll start working.
$('div').on('click', $.proxy(example, this));
async function example() {
console.log('test');
}