> For the complete documentation index, see [llms.txt](https://khaled-hamam.gitbook.io/design-patterns-explained/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://khaled-hamam.gitbook.io/design-patterns-explained/library/behavioral-patterns/mediator/example-1.md).

# Example 1

This example is a simple `Pub/Sub` pattern implementation, where the components talk to each other by publishing and subscribing to events through the mediator.

## Mapping The Example to Structure

* PubSub **::** ConcreteMediator
* ServicesClasses **::** Component

## UML

![Example 1 UML Diagram](https://2149973296-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKKrm5lFe01Ro4BXbPp%2Fsync%2Ff98bd5da0a3ef5784ba37c91a29f5c9ed312b8e3.svg?generation=1607704371423095\&alt=media)

## Files

* [Source Code](https://github.com/khaled-hamam/design-patterns-explained/tree/9c2a4bbf5510f54aacb4e38dd51b327165555da0/library/behavioral-patterns/mediator/example-1/index.ts)
* [Tests](https://github.com/khaled-hamam/design-patterns-explained/tree/9c2a4bbf5510f54aacb4e38dd51b327165555da0/library/behavioral-patterns/mediator/example-1/index.test.ts)
