Table of Contents generated with DocToc
"is a design pattern that allows us to expose a unified interface through which the different parts of a system may communicate" - Essential JS design patterns, Addy Osmani
It's also normally defined as a behavioral pattern.
Example:
const orgChart = {
addEmployee: function(){
const details = this.getDetails();
details.on('ev1', function(){
const manager = this.getManager(employee);
manager.on('ev2', function(){
employee.save();
});
});
}
}
Pros
- Reduces the interaction between different parties from many to one
- Helps in the process of decoupling objects which often promotes smaller, reusable components.
Cons
- Introduces a single point of failure