We are in the process of creating a widget screen that contains various widgets/modules:
- Products: Displays a list of products
- Product Details: Retrieves product details from the server when a selection is made in the "Products" widget.
- Related Products: Retrieves related products from the server when a selection is made in the "Product" widget.
- Compare: Performs certain actions on the server when the "Compare" button in the "Product Details" widget is clicked.
While this may sound straightforward, we are facing a challenge in determining how these components should communicate with each other. We aim for them to be loosely coupled, meaning that the "Products" widget shouldn't need to know about the existence of the "Product Details" and "Related Products" widgets. Additionally, some widgets may not even be visible on the screen at all times, requiring no action.
The only solution we have considered so far is using $rootScope.$broadcast and $rootScope.$on to handle events like "ProductSelectionChanged" or "CompareClicked".
However, we have encountered concerns regarding performance issues with $rootScope.$broadcast, as discussed here: What's the correct way to communicate between controllers in AngularJS?. Furthermore, the suggested alternative by Christoph using $rootScope.$emit is incompatible with IE8.
Should we stick with using $rootScope.$broadcast or do you have a better suggestion?
Thank you for your assistance!
Best regards, Michael