From the course: JavaScript: Patterns
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Chain of responsibility - JavaScript Tutorial
From the course: JavaScript: Patterns
Chain of responsibility
- [Instructor] The Chain of Responsibility is a pattern to help solve common practical issues of having a request from a client and needing this request to pass through multiple functions or logic to get the result. This is where chain of responsibility comes into play. So let's illustrate this with an example. When you hit the Buy button, this particular request goes through a series of functions to finalize the order, and they can quickly grow in complexity. So we hit the Buy button, then the application needs to check if you're logged in, then needs to check if it has your address. If not, add an address. Then it needs to calculate the taxes, shipping, process payment, and finally process the order, and display success message. Needles to say, this simple action of clicking by has several functions related to it, and if we are to build this application with a modular approach and pure functions, we're talking close to a…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
What are behavioral patterns?1m 4s
-
(Locked)
Observer pattern2m 36s
-
(Locked)
State pattern3m 6s
-
(Locked)
Chain of responsibility1m 30s
-
(Locked)
Iterator pattern3m 44s
-
(Locked)
Strategy pattern1m 36s
-
(Locked)
Memento pattern53s
-
(Locked)
Mediator pattern1m 32s
-
(Locked)
Command pattern2m 24s
-
(Locked)
-