Stack Explorer

Observer Pattern

behavioral

Notify multiple objects about state changes

Type: pattern

Principles

Subject maintains list of observersObservers subscribe/unsubscribeAutomatic notification on changes

When to use

Reactive UIs, event systems, pub/sub

When not to use

Simple dependencies, single observer

Pros and Cons

Ventajas

  • + Low coupling
  • + Broadcast changes
  • + Add observers dynamically

Desventajas

  • - Undefined notification order
  • - Memory leaks if not unsubscribed
  • - Update cascades

Related Technologies

Related Patterns