Summary
In this chapter, we learned about the Observer Pattern, how it can make the HTML code of our web pages cleaner, and the way that decouples it from our application's code. We learned how jQuery adds a protection layer to its methods in order to protect us from undetected memory leaks, which may occur by adding observers to elements, when not using the jQuery DOM manipulation methods.
We also tried the Delegated Event Observer Pattern variant and used it to rewrite our initial example. We compared the two implementations and saw how it simplifies writing code that applies to many page elements when they are generated after the page has been loaded. Finally, we had a comparison regarding the memory consumption of the plain Observer Pattern with its delegate variant and highlighted how it also lessens the memory consumption of our page by reducing the required number of attached observers.
Now that we have completed our introduction on how the Observer Pattern is used to listen to...