From the course: Practical Design Patterns in Swift

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Request propagation

Request propagation - Swift Tutorial

From the course: Practical Design Patterns in Swift

Start my 1-month free trial

Request propagation

- [Instructor] The chain of responsibility design pattern decouples the sender of a request from its potential receivers. The receivers form a chain, and the request travels along this chain. The first object receives the request. If it's not interested in the specific request, it forwards it to the next receiver. The request travels until one of the objects processes the request or until we reach the end of the chain. The chain is implemented as a single-linked list with each receiver holding a reference to its successor in the chain. The end of the chain is either a new reference or a reference to a special type. We can manage the chain of responders dynamically by adding new responders or removing existing ones from the list. In some cases, the responder may forward the request through the chain after it handles it. This way, multiple responders can process the same request. This is how iOS or MacOS handle house clicks and taps on the user interface. The chain of responsibility…

Contents