O'Reilly logo

Mastering JavaScript Object-Oriented Programming by Andrea Chiarelli

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The publish/subscribe pattern

We will try to overcome the limitations of previous data binding implementations by using a design pattern. We can choose to apply the observer pattern or publisher/subscriber pattern. Both are intended to manage a scenario where one or more objects are interested in receiving notifications when the state of another object changes. The solutions proposed by the patterns are similar and often the two patterns are confused or considered as two different names for the same pattern. Actually, there are important differences, as we will see in the following sections.

The observer pattern

The observer pattern is maybe widely known because it is included in the patterns proposed by the Gang of Four. In its simplified version ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required