The Observer pattern methods

There are two different ways of notifying the Observer of the changes that happen in the Subject. They can be classified as push or pull models.

The pull model

In the pull model, Observers play an active role as follows:

  • The Subject broadcasts to all the registered Observers when there is any change
  • The Observer is responsible for getting the changes or pulling data from the subscriber when there is an amendment
  • The pull model is ineffective as it involves two steps—the first step where the Subject notifies the Observer and the second step where the Observer pulls the required data from the Subject

The push model

In the push model, the Subject is the one that plays a dominant role as follows:

  • Unlike the pull model, the changes ...

Get Learning Python Design Patterns - Second Edition 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.