Imagine that Main.c
s calls sub.cs
which calls action.cs
. action.cs
raises and event which sub.cs
subscribes to, however, sub.cs
does not care about the event it is only main.cs
that wants to know about this so sub.cs
raises the event again so that main.cs
can subscribe to it and discover that action.cs
has raised the original event; which seems so cumbersome.
What alternatives are there to passing events on through a chain of method calls?
You could use a callback instead of events.
You can add a callback function as additional parameter to the methods of method chain.
E.g. if the method is doSomething()
replace it with doSomething(Action action)
and Main.c calls this method with Sub.doSomething(() => ReactToTheEvent());
and Action.cs calls action();
insetad of raising the event.