From the course: JavaScript: Patterns

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Command pattern

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…

Contents