Chapter    22

The Observer Pattern

The observer pattern is used to manage the process by which one object expresses interest in—and receives notification of—changes in another. The observer pattern allows large and complex groups of objects to cooperate with one another with few dependencies between them and is so widely used that you are likely to have come across it if you have developed an application using a modern UI component framework. Table 22-1 puts the observer pattern in context.

Table 22-1. Putting the Observer Pattern into Context

Question

Answer

What is it?

The observer pattern allows one object to register to receive notifications about changes in another object without needing to depend on the implementation of that object.

What ...

Get Pro Design Patterns in Swift 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.