Loosely coupled communication
Check our Francis Cheung's blog posts on loosely couple communication for composite WPF applications. Francis discusses three mechanisms for loosely coupled communication:
- Shared Services
- Commanding
- Event Aggregation
Francis (did most of the work) and I identified some guidelines on when to use each of these mechanisms. Let us know your thoughts on the guidance as this is input to our Prism documentation.
Guidelines for loosely coupled communication
When communicating between modules you can use Shared Services, Commanding, or Event Aggregation. Use the following to help decide which approach to use:
- If you need to respond to a user gesture, such as clicking on a command invoker (button, menu item.), and you want the invoker to be enabled based on business logic, use Commanding
- If you need to fire an event and do not need a response, use an Event Aggregator
- Otherwise consider using a service locator to register and resolve Shared Services