LearningTech

Behavioral

Observer

Description

Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they're observing.

Where to use

  • Event handling systems.
  • \n
  • UI Updates.

Real World Example

A Spreadsheet. If you change value in Cell A1, the Chart observing A1 automatically updates.

Code Example

class Observer:
    def __init__(self):
        pass

    def execute(self):
        print('Executing Observer')