Ayumilove Observer Design Pattern

Observer Design Pattern Overview

  • When a subject changes state, it notifies all the subscribers (one to many relationship).

Before

After #1 (Push Method)

  • The subscribers are provided data from the publisher via update function parameter.
  • 1 or more displays (bar/pie) can subscribe and unsubscribe during runtime.
  • Adding/Removing subscribers from publisher does not changes publisher’s class.

After #2 (Pull Method)

  • The subscribers retrieve data directly from the publisher’s class via function calls.
  • 1 or more displays (bar/pie) can subscribe and unsubscribe during runtime.
  • Adding/Removing subscribers from publisher does not changes publisher’s class.

Leave a Reply

Your email address will not be published. Required fields are marked *