Using C# event types
Before we dive into this section, let’s remember that the Gang of Four text covered the original Observer pattern in 1994. Many languages back then didn’t have built-in events, closures, or systems to easily decouple components. This left programmers to figure out efficient and scalable solutions on their own, with the Observer pattern coming out on top. This doesn’t mean the original Observer pattern structure should be thrown out if your language has these built-in tools, which C# and Unity both have.
The original pattern is still very useful for a one-to-many relationship between subject and observers (the waterfall analogy where you want observers to know everything happening downstream), but there are many common scenarios where that’s not enough, where observers may need to observe more than one subject at a time (we’ll call this the buffet scenario). In those many-to-many cases, we’re lucky enough to have the...