Inter-Component Communication via Delegates

Let’s assume the following Actor, which has ComponentA and ComponentB.

          Actor
            |
     ---------------
     |             |
ComponentA    ComponentB

Let’s assume ComponentA needs to keep ComponentB updated about a value, in case this value ever changes. ComponentB would then need to adjust some of its own values in response.

And let’s also assume, I wanted to solve this problem using Delegates — keeping both of the Components loosely coupled and modular as they in theory should be. No hard references.

I know about the different types of Delegates and their usage and I have created my fair share of Components over the last few months while learning. So I should be familiar with the basics needed to solve this problem.

Which brings me to the question of the correct or at least most common approach to this scenario with a minimum of coupling and a maximum of modularity.
Should I forward the Delegate from ComponentA to ComponentB via the owning Actor to prevent direct coupling between the two Components or is there a better approach I am not aware of?

1 Like