From the course: JavaScript: Patterns

Unlock the full course today

Join today to access over 24,900 courses taught by industry experts.

Mediator pattern

Mediator pattern

- [Emmanuel] The mediator pattern provides a set of objects which interact with each other, mostly by having a central authority dictating the terms in between objects. It is best demonstrated with example code. Take a look at the exercise files, and pull the files from this video. You'll see here an example that is often used to demonstrate the mediator pattern. So basically what we have here is first a class called TrafficTower, so we're creating a tower, and inside of that tower we have a list of all the airplanes. And then we can actually request all the positions of the airplanes from that TrafficTower. And then we have a class called Airplane, and we're basically building a constructor with the position and trafficTower, and so on and so forth. And then we have a function that requests positions from the traffic tower. So basically the airplane can actually track itself from the traffic tower and then the…

Contents