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 ...
Get Mastering JavaScript Object-Oriented Programming 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.