Book Image

Node.js High Performance

By : Diogo Resende
Book Image

Node.js High Performance

By: Diogo Resende

Overview of this book

Table of Contents (14 chapters)

Event-driven architecture


Developing in Node.js is no different from other languages. You have some more or less native patterns, widely adopted and fully supported. One very common pattern is event-driven architecture. This pattern promotes production and consumption of events. This means that your code should be reactive to events instead of constantly trying to detect changes. Usually, many listeners can consume an event. There are some variations, such as having a way of stopping the event propagation or only allowing the first listener to consume the event, but normally all listeners will be able to consume all the events that they're listening to.

This pattern is very effective when you need to communicate inside your application in a one to many module of your code, as it gives you a very lose coupling. This is specifically interesting in service-oriented architecture (SOA) as it ensures your application components (your services) remain loosely coupled and can be upgraded over time...