$(document).on('custom-event', listener1 );
$(document).on('custom-event', listener2 );
function listener1() {
return new Promise((resolve) => {
setTimeout(resolve, 3000);
})
}
function listener2() {
return new Promise((resolve) => {
setTimeout(resolve, 10000);
})
}
$(document).trigger('custom-event');
const afterAwaiting = true; // Need to await 10 seconds after previous line of code to execute this statement
I've triggered custom Event - custom-event
.
Need to await All of the Listeners execute its code,
then continue to execute next statement.