Skip to content

Instantly share code, notes, and snippets.

@g-akshay
Last active February 21, 2017 18:24
Show Gist options
  • Select an option

  • Save g-akshay/5782d4e44ad3371535b38d211b4ad8e1 to your computer and use it in GitHub Desktop.

Select an option

Save g-akshay/5782d4e44ad3371535b38d211b4ad8e1 to your computer and use it in GitHub Desktop.
Mediator Pattern

Examples

  • A real-world analogy could be a typical airport traffic control system. A tower (Mediator) handles what planes can take off and land because all communications (notifications being listened out for or broadcast) are done from the planes to the control tower, rather than from plane-to-plane. A centralized controller is key to the success of this system and that's really the role a Mediator plays in software design.
  • Another analogy would be DOM event bubbling and event delegation. If all subscriptions in a system are made against the document rather than individual nodes, the document effectively serves as a Mediator. Instead of binding to the events of the individual nodes, a higher level object is given the responsibility of notifying subscribers about interaction events.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment