← Back to design patterns map
📦
Design Pattern

Command

Wrap an action as an object so it can be queued, logged, or undone.

behavioral

Visual Diagram

Client creates command
-> queue/log/execute
-> optional undo

When To Use

  • ->Undo and redo
  • ->Background jobs
  • ->Retry queues
  • ->Audit logging actions
Used in: BullMQ jobs, task queues, undo stacks
command.js

Live Editor

Loading...

Output

Run code to see output...