Design Patterns · Junior · Question 6 of 75

How does the Observer pattern work?

Explanation

The subject provides subscribe/unsubscribe and calls callbacks on change. Web examples: addEventListener, store subscriptions in Redux and Zustand, RxJS. The key thing is to remember to unsubscribe, otherwise you get memory leaks.

Further reading

Problem with a question

Design Patterns · Junior · question 6

Test yourself

Take the Design Patterns · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz