Advantages

The observer pattern helps to find out relationships between different modules in detail. As the user knows relationship of modules in detail, they can easily design subjects and observers objects. This way of designing code can help us break down modules into smaller task, which at the end turns into quality code and improve reusability of code in the system.

Next point, which encourages us to use the observer pattern, is to provide consistency between subjects and observers objects without making objects tightly coupled. For example, the Observable object doesn't need to worry about details of observers while notifying these objects.

We can add or remove observers at runtime, which can lead us to achieve a concept called Hot Swapping ...

Get Test-Driven JavaScript Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.