Observer_Pattern

Observer Pattern

Intro

1 - > N

Pros

  • Broadcasting everything at once.
  • Big state change and you need to reflect that everywhere.

Cons

  • Subscribing and disposing of subscribers
  • Multiple firing of events.
  • Hot / Cold observers

Examples

iOS examples of observer pattern in simple Swift way and Combine Reactive paradigm way.

notification_pattern

swift keypaths

Key - Value Coding KVO pattern

combine Publisher

combine Subjects

rxSwift subscribe

rxSwift subjects

closure