โ† CS Visual Lab ยท Design Patterns

๐Ÿ‘€ Observer

๐Ÿ’ก The ideaOne object (the subject) keeps a list of observers and notifies all of them when it changes. The basis of events, listeners and pub/sub.
๐Ÿ  In real lifeA YouTube channel (subject) and its subscribers (observers): a new video notifies every subscriber.

๐ŸŽฌ Watch it work

Step 1 of 4
Subscribe
SubjectObserver AObserver B

Observers register with the subject.

subject.subscribe(a); subject.subscribe(b);

โœ… Check yourself (2 of 3 to pass)

1. Observer is a โ€ฆ pattern.
2. In Observer, who keeps the list of listeners?
3. A real example of Observer is:
Next: Strategy โ†’Get a free certificate in Design Patterns