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

233
Visualizações
Nodejs - It is wrong to mix Promise based architecture with events

I'm working on a nodejs app that will become larger. I don't find a lot of ressources for advanced Nodejs project architecture and structure. I would like to know if it's an antipattern to mix paradigm of promises with Events in NodeJS.

If someone have ressources about advanced project architecture or open source large Nodejs projects, it could really help me.

Best regards.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

It is not wrong to mix Promises and callbacks. Sometimes it is necessary, especially if a library or existing code only has one or the other. Callbacks and Promises are just ways of handling the asynchronous nature of NodeJS, so just be aware of controlling the flow of your program.

Some other thoughts:

  • I find it easier to use Promises inside of callback functions, as you can use the Promise resolution to determine when and how to call the callback

  • If possible, promisify your callbacks (or even other callback libraries) if you can! That might be a personal preference of mine since I like promises more. Some libraries even allow you to go from Promises to callbacks, but I haven't done that.

  • The ES6 async/await stuff changes things again! So keep adapting as you are able, or as you need to.

  • There is nothing wrong with callbacks or Promises. No wrong choice and it's ok to mix, just keep control flow in mind.

over 4 years ago · Santiago Trujillo 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