I don't get how to resolve a promise from an other function.
How can 1. tell to blabla() 'mail received' by sending the mail?
mail.on('new', function(mail) {})
This module do stuff and at some point must wait for the_mail, before continuing.
function blabla() {
[.. I do stuff ..]
console.log('now we must wait for a new mail')
const the_mail = await waiting_for_mail()
[.. I can continue stuff (I have the mail) ..]
}
Well, I have very little to go on here, but here's a suggestion from what I could gather:
function waiting_for_mail() {
return new Promise(resolve => {
mail.once('new', resolve);
});
}