Mediator
The Mediator pattern is like a more civilized version of the Pub Sub pattern. The Pub Sub pattern is just a bunch of modules yelling at each other: “I’M A TAB AND I HAVE BEEN SELECTED, IF ANYBODY CARES!” The trouble with all this yelling becomes apparent when there are conflicts. If two tabs publish the tabSelected event at the same time, which tab actually gets selected? If one tab publishes the tabSelected while another tab is in a frozen state (tabs can be frozen when an alert or prompt window is open), do the tabs switch anyway? Should they? When modules can communicate only through events, these types of conflicts can result in some strange behavior. If you try to fix this behavior while still using only events, your modules might ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access