The Observer Pattern: Observable Objects

Learn how to make objects observable and how to deal with memory leaks.

Making any object observable

In the Node.js world, the EventEmitter class is rarely used on its own. Instead, it’s more common to see it extended by other classes. In practice, this enables any class to inherit the capabilities of the EventEmitter class, therefore becoming an observable object.

To demonstrate this pattern, let’s try to implement the functionality of the findRegex() function in a class, as follows:

Get hands-on with 1400+ tech skills courses.