Summary

The asynchronous development style using callbacks that is a recurring pattern in JavaScript and Node.js applications can at times result in a code structure that is hard to understand. Applying the event emitter pattern comes in handy in situations where more than one callback event must be handled, resulting in a cleaner code structure that is easier to follow and reason about. The pattern is so useful that we should use it for our own objects and functions where it makes sense, something that's made easy by utilizing the existing util.inherits class.

Get The Node Craftsman Book now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.