I have an async
function that performs an action. I need to wait for that action to complete by listening to an EventEmitter
event.
In the below example url
is obtained in the new
event of the maildev EventEmitter
. We want to wait for a new mail in order to continue the async
function.
maildev.on('new', callback(mail) { return mail.url })
(async () => {
await send_semail();
const url = await // Wait for maildev.on('new', callback(mail)) to be fired
await visit(url);
})()