Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

193
Visualizações
Will events be emitted / captured while awaiting for a promise?

I'm kinda new to nodejs and I'm familiarizing myself with the event loop, queue, etc.

I was wondering what happens while I'm awaiting for a promise to resolve, regarding events. Will events be emitted while awaiting? (I'm subscribed to a message broker, getting a message triggers an event). Will the callbacks that are called on event be queued in the event queue?

I know that the callback won't be executed until the promise resolves but will the events be triggered?

Thanks ^^

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

When events are registered, their emission is simply controlled by whatever makes them emitted. However, the callback registered to handle the event would go first into the event queue, and their queue position is not determined by what other promises are awaiting resolution, rather the position is determined by whatever promises have been resolved or rejected and whatever events have been emitted ahead of the presently emitted event, and they will all wait for the call stack to be cleared before they are invoked in turn. The event loop is the process of doing that, that is, it executes tasks from the event queue only when the call stack is empty i.e. there is no ongoing task.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda