Exploring the Event Bus
The first programming pattern we’ll look at is the Event Bus. It will help us to decouple code, meaning that two pieces of code don’t need to rely on each other too much while still being able to communicate.
Let’s take a look at what problem the Event Bus pattern tries to solve.
The problem
If we decouple different classes and parts of our code, they are easier to reuse later on. We did this earlier, in Chapter 9 for example, with the signals that we can connect provided by Godot Engine. The piece of code that publishes the signal does not care about who is listening or wants to receive that signal.
But signals only work very locally, and using them globally can turn out to be a challenge. The classic example is an achievement system. Achievements are little rewards that a player gets when accomplishing certain tasks within a game. These could even be linked to external achievement systems like the ones from Steam or PlayStation...