← Back to design patterns map
🎛️
Design Pattern

Mediator

Centralize communication so objects do not talk directly to each other.

behavioral

Visual Diagram

Component A
-> Mediator
-> Component B/C

When To Use

  • ->Components should not depend directly on each other
  • ->Chat rooms or socket hubs
  • ->Event bus coordination
  • ->CQRS command and event buses
Used in: Event bus, message broker wrappers, NestJS CQRS bus
mediator.js

Live Editor

Loading...

Output

Run code to see output...