In the previous chapter, we added a service layer to our architecture. We are going to follow the same pattern. Also, we are going to add an extra component called Mediator
, which will serve as a single point of entry to assist us in communicating with different modules.
We will follow the mediator design pattern in the construction of our modules, which is a behavioral design pattern. This is going to be a single central point of control, through which communication flows.
Our Mediator
is going to be an object that will coordinate interaction with different modules through channels. A module can subscribe to a given event and get notified when that event occurs. All this event-related discussion pretty much makes us think about using the events core module from Node.js, which is used to emit named events that cause execution of the functions to be called.
This is a good starting point. One thing we need to solve is that our Mediator
needs to be a single point of...