Command Pattern

Learn about the Command design pattern and its typical configuration.

Another design pattern with huge importance in Node.js is the Command pattern. In its most generic definition, we can consider a command any object that encapsulates all the information necessary to perform an action at a later time. So, instead of invoking a method or a function directly, we create an object representing the intention to perform such an invocation. It’ll then be the responsibility of another component to materialize the intent, transforming it into an actual action. Traditionally, this pattern is built around four major components, as shown in the illustration below.

Get hands-on with 1400+ tech skills courses.