Chapter    19

The Chain of Responsibility Pattern

The chain of responsibility pattern is useful when there are multiple objects that could take responsibility for a request but you don’t want to expose details of those objects to the calling component. Table 19-1 puts the chain of responsibility pattern into context.

Table 19-1. Putting the Chain of Responsibility Pattern into Context

Question

Answer

What is it?

The chain of responsibility pattern organizes sequentially a set of objects that may be able to take responsibility for a request from a calling component. The sequence of objects is referred to as a chain, and each object in the chain is asked to take responsibility for the request. The request moves along the chain until one of the objects ...

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.