HTML and CSS Reference
T he Observer pattern (also known as Publish/Subscribe, or simply pub/sub)
is a design pattern that allows us to observe the state of an object and be notified
when it changes. The pattern can provide objects with powerful extension points
while maintaining loose coupling.
In this chapter we will let tests drive us through our first library. By focusing on
avoid the world of the DOM, staying clear of the nastiest browser inconsistencies.
Working through this chapter will show you how to
Design an API using tests.
Continuously improve design by refactoring—both tests and production
Add functionality one tiny step at a time.
Solve simple browser inconsistencies with the help of unit tests.
Evolve from classical language idioms to idioms that make better use of
There are two roles in The Observer— observable and observer . The observer is
an object or function that will be notified when the state of the observable changes.
The observable decides when to update its observers and what data to provide
them with. In classical languages like Java, notification happens through a call to