Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Containers should not have knowledge of their components or how they behave. A container's responsibilities are typically the domain of instantiation dependency - not communication dependency. A container should be a generalized factory.</p> <p>This is the reason why structural graph != communication graph. As I am sure you have realized, as a factory a container is the root of your object graph, but a container responding to or publishing an event simply does not make sense.</p> <p>What you want then, is someone who's job it is to manage events. A specialized component that knows <em>about</em> events, and can <em>broker</em> an instance of one to interested parties. You want a generalized event broker. An event router if you will.</p> <p>You could probably find many implementations of one. Such as Cab's EventBroker, Prism's event aggregator, or my favourite <a href="http://kentb.blogspot.com/2008/03/event-hub.html" rel="nofollow noreferrer">EventHub</a>. This last one is a culmination of experience from working with Cab extensively and correspondence with Jeremy Miller and Glenn Block, by <a href="https://stackoverflow.com/users/5380/kent-boogaart">Kent, a very cool guy</a>.</p> <p>If you are using a container, you are likely familiar with Dependency Injection and Inversion of Control. Someone who needs to publish events is injected an IEventHub and invokes Publish with a strongly typed subject class. Someone who needs to subscribe to an event is also injected an IEventHub and implements a strongly typed ISubscriber interface [which basically exposes a strongly typed Receive method]. That's it.</p> <p>Now events can travel any which way [as business requirements permit], as they should.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload