The Event Bus acts as a central hub that manages a specific list of global events that objects can choose to subscribe to or publish. It's the most straightforward pattern related to event managing that I have in my toolbox. It reduces the process of assigning the role of subscriber or publisher to an object into a single line of code. As you can imagine, this can be beneficial when you need results quickly. But like most simple solutions, it has some drawbacks and limitations, which we will explore further on.
In the code example presented in this chapter, we will use the Event Bus to broadcast specific race events to components that need to listen for changes in the overall state of the race. But it's essential to keep in mind; I'm proposing using the Event Bus as a solution for managing global race events because of its...