From the course: JavaScript: Patterns
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Command pattern - JavaScript Tutorial
From the course: JavaScript: Patterns
Command pattern
- [Instructor] The command pattern is one that encapsulates actions or operations as objects. So in other words, in this pattern you abstract the actual function or execution of the action from the action itself. And if this sounds a bit weird, it is best represented through code. But if you have been using Redux for any amount of time you've used the command pattern. Which is where we use it by extracting the actions, which are called from the execution of the actions, which are reducers. It is also often used in functional programing. So let me show you through code on the Redux website. So go to Redux.js.org and go in the Getting Started section. And then scroll to the Basic Tutorial, click on it, and then find the Example Todo List. So this is a good example of a program or todo list, where we can actually see reducers, actions, and the container components in action, or the command pattern. So basically, you have the…
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)
-