Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!